Sei sulla pagina 1di 16

Reminder:Hypothesis tests

Hypotheses
H0: Null-hypothesis is an conjecture which we assume is
true until we have too much evidence against it.
H1: The alternative hypothesis covers the alternative to H0

Notice: We either reject or cannot reject the null-hypothesis


– we never accept (or prove) the null-hypothesis.
We can reject H0 in three equivalent way:
 The test statistic is in the critical area
 The p-value < α
 Hypothesised value (e.g. µ0) is outside the confidence
intervals (only for two-sided tests)
1 lecture 9
Reminder:Test of mean
Variance unknown (two-sided)
Hypotheses: Significance level:
H 0 : µ = µ0  X − µ0 
P − tα / 2,n −1 < < tα / 2,n −1  = 1 − α
H1 : µ ≠ µ 0  s/ n 

Test statistic: Critical values:


x − µ0 − tα / 2,n −1 , tα / 2,n −1
t=
s/ n

Decision: Reject H0 if z does not lie between


the critical values.
2 lecture 9
Test of variance
Two-sided test
Hypotheses: Significance level:
H0 :σ = σ 0  2 (n − 1) s 2 2 
P χ1−α / 2 < < χα / 2  = 1 − α
H1 : σ ≠ σ 0  σ02

Test statistic: Critical values:


(n − 1) s 2
χ2 = χ12−α / 2 , χα2 / 2
σ 02

Decision: Reject H0 if χ2 does not lie between


the critical values
3 lecture 9
Test of variance
Problem: A company produces
golf balls, where the standard
deviation of the diameter is not
allowed to exceed 0.5 mm. Bente
wants to prove that the variation is
higher, and so measures 10 golf
balls. The sample standard
deviation is 0.6 mm.
Is Bente’s claim correct?
Formulate the hypotheses and test it the
using a 5% significance level.

4 lecture 9
Test of variance
The MATLAB way
Data σ20 = 0.52 H0: σ2 ≤ σ20
>> [h,p,ci,stats]=vartest(x,0.5^2,0.05,‘right')

h = Significance level α = 0.05


h=0: H0 not rejected
0 h=1: H0 rejected
p =
0.1644 p-value
ci =
0.1915 (1-α)100% confidence interval
Inf
stats =
chisqstat =
(n − 1)s 2
chisqstat: 12.9600 σ2
df: 9
df = degrees of freedom

5 lecture 9
Difference in means
Estimation (known variances)

Consider two populations with means µ1 and µ2 and


known variances σ21 and σ22, and two samples of
sizes n1 and n2.

Estimate of µ1 − µ2 :
x1 − x2
Confidence interval:
σ 12 σ 22 σ 12 σ 22
( x1 − x2 ) − zα / 2 + < µ1 − µ 2 < ( x1 − x2 ) + zα / 2 +
n1 n2 n1 n2

6 lecture 9
Test of two means
Known variances (two-sided)
Hypotheses: Significance level:
H 0 : µ1 − µ 2 = d 0
P(− zα / 2 < z < zα / 2 ) = 1 − α
H1 : µ1 − µ 2 = d 0

Test statistic: Critical values:


( x1 − x2 ) − d 0
z= − zα / 2 , zα / 2
σ / n1 + σ / n2
2
1
2
2

Decision: Reject H0 if z does not lie between


the critical values
7 lecture 9
Test of two means
Unknown & equal variances (two-sided)

Test statistic: Pooled variance estimate:


( x1 − x2 ) − d 0 ( n − 1) s 2
+ ( n − 1) s 2
t= s 2p = 1 1 2 2

s p 1 / n1 + 1 / n2 n1 + n2 − 2

Critical values: Degrees of freedom

− tα / 2,v , tα / 2,v v = n1 + n2 − 2

8 lecture 9
Test of two means
Unknown & unequal variances (two-sided)

Test statistic:
( x1 − x2 ) − d 0
t=
s12 / n1 + s22 / n2
Degrees of freedom:
Critical values:
( s12 / n1 + s22 / n2 ) 2
− tα / 2,v , tα / 2,v v= 2
( s1 / n1 ) 2 ( s22 / n2 ) 2
+
n1 − 1 n2 − 1

9 lecture 9
Test of variance

Problem: Bente claims that golf


balls from company A and
company B are not of the same
size. She obtain two samples:
Company A: x1 = 41.6 s1 = 0.5 n1 = 10
Company B: x2 = 41.1 s2 = 0.6 n2 = 8

Is Bente’s claim correct?


Formulate the hypotheses and test it the
using a 5% significance level. Assume equal
variance.
10 lecture 9
Test of two means the MATLAB way
Equal unknown variance (two-sided)
Data H0: µ1 - µ2 =0 σ21 = σ22
>> [h,p,ci,stats] = ttest2(x,y,0.05,'both','equal')

h = Significance level α = 0.05


h=0: H0 not rejected
0 h=1: H0 rejected
p =
0.0715 p-value
ci =
-0.0490 (1-α)100% confidence interval for µ1 - µ2
1.0490
stats = ( x1 − x2 ) − d 0
tstast =
tstat: 1.9305 s p 1 / n1 + 1 / n2
df: 16
sd: 0.5460 df = degrees of freedom

( n − 1) s 2
+ ( n − 1) s 2
tstast = s 2p = 1 1 2 2
n1 + n2 − 2
11 lecture 9
Ratio of variances
Estimation
Consider two populations with variances σ21 and σ22
and two samples of sizes n1 and n2.

Estimate for σ21 / σ22 :


s12 s22
Confidence interval:
s12 1 σ 12 s12
< 2 < 2 fα / 2,n2 −1,n1 −1
s2 fα / 2,n1 −1,n2 −1 σ 2 s2
2

12 lecture 9
Test of two variances
Two-sided test
Hypotheses: Significance level:
H0 : σ1 = σ 2
( )
P 1 / fα / 2,n2 −1,n1 −1 < f < fα / 2,n2 −1,n2 −1 = 1 − α
H1 : σ 1 ≠ σ 2

Test statistic: Critical values:


s12 1 / fα / 2,n2 −1,n1 −1 , fα / 2,n1 −1,n2 −1
f = 2
s1

Decision: Reject H0 if f does not lie between


the critical values.
13 lecture 9
Test of equal variance
Problem: Bente now wants to
compare two companies to see if
one company makes more equally
sized golf ball that the other. For
company A she obtains a sample
std. div. of 0.5 mm for 10 golf balls,
and for company B she obtains a
sample std. div. of 0.6 mm for 8
golf balls.
Is there a significant difference? Test this
using a 10% significance level.

14 lecture 9
Test of equal variance
The MATLAB way
Data pop. A Data pop. B
>> [h,p,ci,stats] = vartest2(x,y,0.1)

h = Significance level α = 0.1


h=0: H0 not rejected
0 h=1: H0 rejected
p =
0.5972 p-value
ci =
0.1889 (1-α)100% confidence interval
2.2866
stats = s12
fstat: 0.6944 fstat = 2
s2
df1: 9
df2: 7 df1 and df2 = degrees of freedom

15 lecture 9
A couple of comments

 Overview of tests of means on page 351


 In the next and final lecture we’ll have a brief
look a Bayesian statistics – a different way of
doing statistics.
 Next time the exercises will consist in you
having a go at some old exam problems.

16 lecture 9

Potrebbero piacerti anche