Mathematical Statistics
Anna Janicka
Lecture XII, 13.05.2019
HYPOTHESIS TESTING IV:
PARAMETRIC TESTS: COMPARING TWO OR MORE POPULATIONS
Plan for today
1. Parametric LR tests for one population – cont.
2. Asymptotic properties of the LR test
3. Parametric LR tests for two populations 4. Comparing more than two populations
ANOVA
Notation
x
somethingalways means a quantile of rank
something
Model III: comparing the mean
Asymptotic model: X1, X2, ..., Xn are an IID sample from a distribution with mean
µ
and variance(unknown), n – large.
H0:
µ
=µ
0Test statistic:
has, for large n, an approximate distribution N(0,1) H0:
µ
=µ
0 against H1:µ
>µ
0critical region
H0:
µ
=µ
0 against H1:µ
<µ
0critical region
H0:
µ
=µ
0 against H1:µ ≠ µ
0critical region
S n T X −
µ
0=
} )
( :
{
* = x T x > u
1−αK
} )
( :
{
* = x T x < u
α= − u
1−αK
}
| ) ( :|
{
* = x T x > u
1−α /2K
Model IV: comparing the fraction
Asymptotic model: X1, X2, ..., Xn are an IID sample from a two-point distribution, n – large.
H0: p = p0
Test statistic:
has an approximate distribution N(0,1) for large n H0: p = p0 against H1: p > p0
critical region
H0: p = p0 against H1: p < p0 critical region
H0: p = p0 against H1: p
≠
p0 critical region) 0 (
1 )
1
( X = = p = − P X =
P
p pp n p
p n p
p p
p U X
) 1
( ˆ )
1
* (
0 0
0 0
0
0
−
= −
−
= −
} )
( :
{
* = x U x > u
1−αK
} )
( :
{
* = x U x < u
α= − u
1−αK
}
| ) ( :|
{
* = x U x > u
1−α /2K
Model IV: example
We toss a coin 400 times. We get 180 heads. Is the coin symmetric?
H0: p = ½
for α = 0.05 and H1: p ≠ ½ we have u0.975 =1.96 → we reject H0 for α = 0.05 and H1: p < ½ we have u0.05 = -u0.95 =-1.64
→ we reject H0
for α = 0.01 and H1: p ≠ ½ we have u0.995 =2.58
→ we do not reject H0
for α = 0.01 and H1: p < ½ we have u0.01 = -u0.99 =-2.33
→ we do not reject H0
p-value for H1: p ≠ ½: 0.044 p-value for H1: p < ½: 0.022
2 ) 400
2 / 1 1
( 2 / 1
) 2 / 1 400
/ 180
* ( = −
−
= − U
Likelihood ratio test for composite hypotheses – reminder
X ~ P
θ, {P
θ: θ ∈ Θ} – family of distributions We are testing H
0: θ ∈ Θ
0against H
1: θ ∈ Θ
1such that Θ
0∩ Θ
1= ∅, Θ
0∪ Θ
1= Θ Let
H
0: X ~ f
0( θ
0,⋅) for some θ
0∈ Θ
0.H
1: X ~ f
1( θ
1, ⋅) for some θ
1∈ Θ
1,
where f
0and f
1are densities (for θ ∈ Θ
0and θ
∈ Θ
1, respectively)
Likelihood ratio test for composite hypotheses – reminder (cont.)
Test statistic:
or
where are the ML estimators for the model without restrictions and for the null model, respectively.
We reject H
0if for a constant .
) ,
( sup
) ,
(
~ sup
0
0 0
0
f X
X f
θ λ θ
θ θ
Θ
∈ Θ
=
∈) ˆ ,
(
) ˆ ,
~ (
0
0
X
f
X f
θ λ = θ
ˆ
0ˆ , θ θ
~ c~
λ > c~
Asymptotic properties of the LR test
We consider two nested models, we test H0: h(
θ
) = 0 against H1: h(θ
) ≠ 0Under the assumption that h is a nice function
Θ is a d-dimensional set
Θ0 = {
θ
: h(θ
) = 0} is a d – p dimensional setTheorem: If H0 is true, then for n→∞ the distribution of the statistic converges to a chi-squared
distribution with p degrees of freedom
λ
~ ln 2degrees of freedom = number of restrictions
Asymptotic properties of the LR test – example Exponential model: X1, X2, ..., Xn are an IID sample from Exp(
θ
).We test H0:
θ
= 1 against H1:θ
≠ 1then:
from Theorem:
for a sign. level
α
=0.05 we have so we reject H0 in favor of H1 ifX MLE(θ ) = θˆ = 1/
(
( 1))
1 exp )
exp(
) exp(
) (
)
~ ( 1 1
1
ˆ = −
Σ
−
Σ
= − Π
= Π n X
X x
x x
f
x f
n i
X i X
i
i n
λ
θ) 1 ( )
ln )
1 ((
~ 2 ln
2 λ = n X − − X →D χ 2 c
c ~ 2ln ~ ln
~ 2
~ > ⇔
λ
>λ
c~
ln 2 84
. 3 )
1
2 (
95 .
0 ≈ ≈
χ
2 / 84 .
~ 3
> e
λ
Comparing two or more populations
We want to know if populations studied are
“the same” in certain aspects:
parametric tests: we check the equality of certain distribution parameters
nonparametric tests: we check whether
distributions are the same
Model I: comparison of means, variance known, significance level
α
X1, X2, ..., XnX are an IID sample from distr N(
µ
X,σ
X2), Y1, Y2, ..., YnY are an IID sample from distr N(µ
Y,σ
Y2),σ
X2,σ
Y2 are known, samples are independent H0:µ
x =µ
YTest statistic:
H0:
µ
x =µ
Y against H1:µ
x >µ
Ycritical region
H0:
µ
x =µ
Y against H1:µ
x≠ µ
Ycritical region
) 1 , 0 (
2 ~
2 Y N
U X
Y Y X
X
n n
σ σ +
= −
} )
( :
{
* = x U x > u
1−αK
}
| ) ( :|
{
* = x U x > u
1−α /2K
assuming H0 is true
Model I – comparison of means. Example
X1, X2, ..., X10 are an IID sample from distr N(
µ
X,112), Y1, Y2, ..., Y10 are an IID sample from distr N(µ
Y,132) Based on the sample:Are the means equal, for significance level 0.05?
H0:
µ
x =µ
Y against H1:µ
x≠ µ
Ywe have: u0.975 ≈ 1.96.
|0.557| < 1.96 → no grounds to reject H0
498 ,
501 =
= Y
X
557 .
498 0 501
10 11 10
132 2
≈ +
= − U
Model II: comparison of means, variance
unknown but assumed equal, significance level
α
X1, X2, ..., XnX are an IID sample from distr N(
µ
X,σ
2), Y1, Y2, ..., YnY are an IID sample from distr N(µ
Y,σ
2) withσ
2 unknown, samples are independentH0:
µ
x =µ
Y Test statistic:H0:
µ
x =µ
Y against H1:µ
x >µ
Ycritical region
H0:
µ
x =µ
Y against H1:µ
x≠ µ
Ycritical region
)}
2 (
) ( :
{
* = x T x > t
1−n
x+ n
y−
K
α)}
2 (
| ) ( :|
{
* = x T x > t1− /2 nx + ny −
K α
Assuming H0 is true
2 1 1
2 1 2 1 1
2 1
) (
, )
( ∑
∑ = − =
− − = −
= Y
Y X
X
n
i i
Y n n
i i
X n X X S Y Y
S
) 2 (
~ ) 2 (
) 1 (
) 1
( 2 2
− +
− + +
− +
−
= − X Y X Y
Y X
Y X
Y Y
X x
n n
t n
n n n
n n S
n S
n
Y T X
Model II: comparison of means, variance unknown but assumed equal, cont.
can be rewritten as
where
is an estimator of the variance
σ
2 based on the two samples) 2 (
~ ) 2 (
) 1 (
) 1
( 2 2
− +
− + +
− +
−
= − X Y X Y
Y X
Y X
Y Y
X x
n n
t n
n n n
n n S
n S
n
Y T X
) 2 (
1 ~
1 + −
+
= −
∗
Y X
Y X
n n
t n
S n
Y T X
2 ) 1 (
) 1
( 2 2
2
− +
− +
= −
∗
y x
Y Y
X x
n n
S n
S S n
Model II: comparison of variances, significance level
α
X1, X2, ..., XnX are an IID sample from distr N(
µ
X,σ
X2), Y1, Y2, ..., YnY are an IID sample from distr N(µ
Y,σ
Y2),σ
X2,σ
Y2 are unknown, samples are independent H0:σ
X =σ
YTest statistic:
H0:
σ
X =σ
Y against H1:σ
X >σ
Ycritical region
H0:
σ
X =σ
Y against H1:σ
X≠ σ
Ycritical region
) 1 ,
1 (
2 ~
2
−
−
= X Y
Y
X F n n
S F S
)}
1 ,
1 (
) ( :
{
* = x F x > F1− nX − nY −
K α
)}
1 ,
1 (
) (
) 1 ,
1 (
) ( : {
*
2 / 1
2 /
−
−
>
∨
−
−
<
=
− X Y
Y X
n n
F x
F
n n
F x
F x
K
α α
assuming H0 is true
2 1 1
2 1 2 1 1
2 1
) (
, )
( ∑
∑ = − =
− − = −
= Y
Y X
X
n
i i
Y n n
i i
X n X X S Y Y
S
Model II: comparison of means, variances unknown and no equality assumption
X1, X2, ..., XnX are an IID sample from distr N(
µ
X,σ
X2), Y1, Y2, ..., YnY are an IID sample from distr N(µ
Y,σ
Y2),σ
X2,σ
Y2 are unknown, samples independent H0:µ
x =µ
YThe test statistic would be very simple, but:
It isn’t possible to design a test statistic such that the distribution does not depend on
σ
X2 andσ
Y2 (values)...2 1 1
2 1 2 1 1
2 1
) (
, )
( ∑
∑ = − =
− − = −
= Y
Y X
X
n
i i
Y n n
i i
X n X X S Y Y
S
?
2 ~
2
Y Y X
X
n S n
S
Y X
+
−
Model III: comparison of means for large samples, significance level
α
X1, X2, ..., XnX are an IID sample from distr. with mean µX, Y1, Y2, ..., YnY are an IID sample from distr. with mean µY , both distr. have unknown variances, samples are independent,
nX, nY – large.
H0: µx = µY Test statistic:
H0: µx = µY against H1: µx > µY
critical region
H0: µx = µY against H1: µx ≠ µY
critical region
) 1 , 0 (
2 ~
2 Y N
U X
Y Y X
X
n S n
S +
= −
assuming H0. is true, for large samples
approximately
} )
( :
{
* = x U x > u
1−αK
}
| ) ( :|
{
* = x U x > u
1−α /2K
2 1 1
2 1 2 1 1
2 1
) (
, )
( ∑
∑ = − =
− − = −
= Y
Y X
X
n
i i
Y n n
i i
X n X X S Y Y
S
Model III – example (equality of means?)
Model IV: comparison of fractions for large samples, significance level
α
Two IID samples from two-point distributions. X – number of successes in nX trials with prob of success pX, Y – number of successes in nY trials with prob of success pY. pX and pY
unknown, nX and nY large.
H0: pX = pY Test statistic:
where
H0: pX = pY against H1: pX > pY critical region
H0: pX = pY against H1: pX ≠ pY critical region
( )
~ (0,1)) 1
* (
1
1 N
p p
n Y n
X U
Y
X n
n Y X
+
−
−
=
∗
∗
} )
( :
{
* = x U
∗x > u
1−αK
}
| ) ( :|
{
* = x U
∗x > u
1−α /2K
y
x n
n
Y p X
+
= +
∗
assuming H0. is true, for large samples
approximately
Model IV – example (equality of probabilities?)
Tests for more than two populations
A naive approach:
pairwise tests for all pairs But:
in this case, the type I error is higher than
the significance level assumed for each
simple test...
More populations
Assume we have k samples:
, and
all X
i,jare independent (i=1,...,k, j=1,.., n
i) X
i,j~N(m
i, σ
2)
we do not know m
1, m
2, ..., m
k, nor σ
2let n=n
1+n
2+...+n
knk
k k
k
n n
X X
X
X X
X
X X
X
, 2
, 1
,
, 2 2
, 2 1
, 2
, 1 2
, 1 1
, 1
,..., ,
...
, ,...,
,
, ,...,
,
2 1
Test of the Analysis of Variance (ANOVA) for significance level
α
H
0: µ
1= µ
2=... = µ
kH
1: ¬ H
0(i.e. not all µ
iare equal) A LR test; we get a test statistic:
with critical region
for k=2 the ANOVA is equivalent to the two-sample t-test.
) ,
1 (
~ ) /(
) (
) 1 /(
) (
1 1
2 ,
1
2
k n
k F k
n X
X
k X
X F k n
i
n
j i j i
k
i i i
i − −
−
−
−
= −
∑ ∑
∑
= =
=
∑
∑ ∑
∑
= = = = = == k
i i i
k i
n
j i j
n
j i j
i
i n X
X n X n
n X
X i i
1
1 1 ,
1 ,
1 , 1
1
)}
, 1 (
) ( :
{
* x F x F
1k n k
K = >
−α− −
ANOVA – interpretation
we have
– between group variance estimator
– within group variance estimator
∑ ∑
= = −−
k i
n
j i j i
i X X
k
n 1 1
2
, )
1 (
Sum of Squares (SS)
Sum of Squares Between (SSB)
Sum of Squares Within (SSW)
∑
= −−
k
i ni Xi X
k 1
)2
1 ( 1
∑ ∑ ∑
∑ ∑
= = − = k= − + = = −i
k i
n
j i j i
i i
k i
n
j i j
i
i X X n X X X X
1 1 1
2 ,
2
1 1
2
, ) ( ) ( )
(
ANOVA test – table
source of
variability sum of squares degrees of freedom
value of the test statistic F between
groups SSB k-1 –
within groups SSW n-k –
total SS n-1 F
ANOVA test – example
Yearly chocolate consumption in three cities: A, B, C based on random samples of nA = 8, nB = 10, nC = 9 consumers. Does consumption depend on the city?
α=0.01
→ reject H0 (equality of means), consumption depends on city
A B C
sample mean 11 10 7
sample variance 3.5 2.8 3
61 . 5 )
24 . 2 (
and
31 . 24 12
/ 7 . 73
2 / 63 . 75
7 . 73 8
3 9 8 . 2 7 5 . 3
63 . 75 9
) 3 . 9 7 ( 10 )
3 . 9 10 ( 8 ) 3 . 9 11 (
3 . 9 )
9 7 10 10
8 11 (
99 . 0
2 2
2 27
1
≈
≈
=
=
⋅ +
⋅ +
⋅
=
=
⋅
− +
⋅
− +
⋅
−
=
=
⋅ +
⋅ +
⋅
=
F F
SSW SSB
X
ANOVA test – table – example
source of
variability sum of squares degrees of freedom
value of the test statistic F between
groups 75.63 2 –
within groups 73.7 24 –
total 149.33 26 12.31