Documente Academic
Documente Profesional
Documente Cultură
(n 1)S 2
2
2
(n 1)S 2
(n 1)S 2 2
2
=
.
2
2
2
0
0
02
(6.1)
142
Pr{21
Pr{21
for H1 ,
for H2 ,
for H3 ,
> (, n 1)},
6 (1 , n 1)},
(6.2)
21, obs
21, obs
or
(6.3)
> (, n 1)},
6 2 (1 , n 1)},
where
21, obs =
(n 1)s2
,
02
(6.4)
(6.5)
However, for non-symmetrical density like this one, the equal-tail approach
leading to the results in (6.5) is not the correct likelihood ratio test.
In the follows, we present a simple method for determine k 1 and k2 (see
Figure 6.1). We denote the density function of the 2 (n 1) by
gn1 (x) =
x > 0,
k2 = (2 , n 1).
and
143
1 gn1 (k1 )
k1
gn1 (k2 ) 2
k2
Figure 6.1 The critical region C1 defined by (6.3) for a two-tailed 2 test, where
gn1 () denotes the density function of the 2 (n 1), and 1 + 2 = .
(6.6)
Especially, when gn1 () is skew toward the left, we always have 0 < 1 <
/2. Thus, we can use the grid method or the bisection method to find 1 .
function(n, alone)
{
# Function name: Compute.alpha.one.chisq.test(n, alone)
# n is the sample size
# alone is a vector consisting of the grid points
# over the interval [0.001, 0.025], e.g.,
# alone = seq(0.025, 0.001, -0.0001)
v <- n - 1
al <- 0.05
L <- length(alone)
k1 <- qchisq(alone, v)
k2 <- qchisq(1 - al + alone, v)
144
}
Example 6.1 Let X1 , . . . , Xn be a random sample from N (, 2 ), and
we observed n = 25 and s2 = 1600. Test H0 : 2 = 02 = 900 against H1 :
2 6= 02 at the 0.05 level of significance.
Solution.
1
k1
12.4012
12.2454
12.0793
11.9010
11.7082
11.4974
11.3840
11.3610
k2
39.364
39.047
38.751
38.472
38.209
37.960
37.840
37.817
gn1 (k1 )
0.01323
0.01244
0.01164
0.01080
0.00994
0.00904
0.00858
0.00849
gn1 (k2 )
0.00609
0.00653
0.00696
0.00739
0.00782
0.00824
0.00845
0.00849
Error
0.0071416
0.0059176
0.0046744
0.0034095
0.0021199
0.0008017
0.0001305
4.7961 10 6
Reject the H0 if 21, obs 6 11.361 or 21, obs > 37.817, where 21, obs is
defined by (6.4).
Since 21, obs = 42.667 > 37.817, the null hypothesis is rejected.
145
Pr{21
21, obs },
for H1 ,
(6.7)
for H2 ,
for H3 ,
subject to b2 > n 3.
(6.8)
Case II: 21, obs > n 3. In this case, we define b2 = 21, obs as shown in
Figure 6.2(ii). The value of b1 can be determined by
gn1 (b1 ) = gn1 (b2 )
(6.9)
Example 6.1 (Revisited). Note that n = 25 and 21, obs = 42.667 > 22 =
n 3, then b2 = 21, obs = 42.667, gn1 (b2 ) = g24 (42.667) = 0.0028345. Now
(6.9) becomes g24 (b1 ) = 0.0028345.
Table 6.2 Calculation of b1 from g24 (b1 ) = 0.0028345
b1
11
10
9.9
9.8
9.7
b1
9.6
9.5
9.4
9.41
9.4095
146
p1 gn1 (b1 )
gn1 (b2 ) p2
b1 = 21, obs
b2
p1 gn1 (b1 )
b1
gn1 (b2 ) p2
b2 = 21, obs
Figure 6.2 The p-value defined by (6.7) for a two-tailed 2 test, where gn1 ()
denotes the density of the 2 (n 1) with mode n 3. (i) 21, obs given by (6.4) is
at the left tail; (ii) 21, obs is at the right tail .
147
6.1.2
Two-sample F test
S12
22 S12 12
12
=
=
F
.
S22
12 S22 22
22
(6.10)
for H1 ,
for H2 ,
= Pr{F0 6 f (1 , 1 , 2 )},
for H3 ,
(6.11)
or
f0 > k2 },
(6.12)
(6.13)
148
and k2 = f (/2, 1 , 2 ).
(6.14)
However, for non-symmetrical density like this one, the equal-tail approach
leading to the results in (6.14) is not the correct likelihood ratio test.
In the follows, we present a simple method for determine k 1 and k2 (see
Figure 6.3). We denote the density function of the F ( 1 , 2 ) by
2
( 1 +
2 )
h1 ,2 (x) =
( 21 )( 22 )
1
2
1
2
1
2
1 x
1+
2
1 +2
2
x > 0,
1 2)2
whose mode is (
1 (2 +2) . The equal-height approach requires to determine
k1 and k2 satisfying (see Figure 6.3):
h1 ,2 (k1 ) = h1 ,2 (k2 )
subject to k1 <
(1 2)2
1 (2 +2)
k1 = f (1 1 , 1 , 2 )
and
k2 = f (2 , 1 , 2 ).
That is, finding k1 and k2 is equivalent to finding 1 and 2 . Since 2 =
1 , we only need to find 1 , which satisfies the following equation:
h1 ,2 (f (1 1 , 1 , 2 )) = h1 ,2 (f ( 1 , 1 , 2 )).
(6.15)
Especially, when h1 ,2 () is skew toward the left, we always have 0 < 1 <
/2. Thus, we can use the grid method or the bisection method to find 1 .
function(n1, n2, alone)
{
# Function name: Compute.alpha.one.F.test(n1, n2, alone)
# n1 and n2 are the sample sizes of the two samples
# alone is a vector consisting of the grid points
# over the interval [0.0001, 0.025], e.g.,
# seq(0.025, 0.001, -0.0001)
v1 <- n1 - 1
v2 <- n2 - 1
149
al <- 0.05
L <- length(alone)
k1 <- qf(alone, v1, v2)
k2 <- qf(1 - al + alone, v1, v2)
hk1 <- df(k1, v1, v2)
hk2 <- df(k2, v1, v2)
error <- abs(hk1 - hk2)
result <- matrix(c(alone, k1, k2, hk1, hk2, error), L, 6)
return(result)
}
Example 6.2 Let Xi1 , . . . , Xini be two independent random samples from
N (i , i2 ), i = 1, 2, and we observed n1 = 13, s21 = 37853.17, n2 = 7,
s22 = 15037.00. Test H0 : 12 = 22 against H1 : 12 6= 22 at = 0.05.
Solution.
1
k1
0.26822
0.23158
0.17370
0.10269
0.10678
0.10864
0.10889
k2
h1 ,2 (k1 )
5.3662 0.31283
4.6648 0.23300
4.1885 0.11615
4.0176 0.02286
4.0212 0.02614
4.0230 0.02772
4.0233 0.02794
h1 ,2 (k2 )
Error
0.011359
0.30147
0.017738
0.21526
0.024730
0.09142
0.028046
0.00518
0.027971
0.00182
0.027934
0.00021
0.027928 1.4163 10 5
Calculate f0 = 2.5173.
150
1 h1, 2 (k1 )
h1, 2 (k2 ) 2
k1
k2
Figure 6.3 The critical region C1 defined by (6.12) for a two-tailed F test, where
h1 ,2 () denotes the density function of the F (1 , 2 ), and 1 + 2 = .
(b) The p-value approach
for H1 ,
for H2 ,
p-value = Pr{F0 6 f0 },
for H3 ,
(6.16)
subject to
b2 >
(1 2)2
.
1 (2 + 2)
(6.17)
Case II: f0 is at the right tail. The value of b1 at the left tail can be
determined by (see Figure 6.4(ii))
h1 ,2 (b1 ) = h1 ,2 (f0 )
subject to
0 < b2 <
(1 2)2
.
1 (2 + 2)
(6.18)
151
p1 h1, 2 (f0 )
f0
h1, 2 (b2 ) p2
b2
(ii) f0 is at the right tail
p1 h1, 2 (b1 )
b1
h1, 2 (f0 ) p2
f0
Figure 6.4 The p-value defined by (6.16) for a two-tailed F test, where h1, 2 ()
2
denotes the density of the F (1 , 2 ) with mode (11(2)
. (i) f0 given by (6.13) is
2 +2)
at the left tail; (ii) f0 is at the right tail .
152
b1
0.170
0.168
0.166
0.1659
0.1658