Download 10.3 Goodness-of-Fit Tests

Survey
yes no Was this document useful for you?
   Thank you for your participation!

* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project

Document related concepts
no text concepts found
Transcript
10.3 Goodness-of-Fit Tests
Ulrich Hoensch
MAT310
Rocky Mountain College
Billings, MT 59102
Case I: All Parameters Known
Theorem 10.3.1
Let Y be a categorical random variable with levels
{y1 , y2 , . . . , yk } and let pi = P(Y = yi ). Suppose the probability
experiment of selecting one of the levels of Y is repeated
independently n times. Let Xi be the random variable that gives
the number of times the i-th level of Y is selected (the observed
count), and let npi be the expected count. Then, if n is large,
the random variable
D2 =
k
X
(Xi − npi )2
npi
i=1
has approximately a chi-square distribution with k − 1 degrees of
freedom.
Chi-Square Test for Goodness of Fit
Suppose a large independent random sample of size n is taken
from a population. Let X1 , X2 , . . . , Xk be the observed counts for
the levels {y1 , y2 , . . . , yk } of a categorical variable Y .
I
Under the null hypothesis H0 : P(Y = yi ) = pi for
i = 1, 2, . . . , k,
I
the test statistic
D2 =
k
X
(Xi − npi )2
∼ χ2 (k − 1).
npi
i=1
I
Let d 2 =
Pk
i=1 ((xi
− npi )2 /npi ). The p-value is:
p = P(D 2 ≥ d 2 ) = χ2 cdf(d 2 , 1E 99, k − 1).
Note. The following rule of thumb is commonly used: npi ≥ 5
for all levels.
Example 1
Suppose 32 independent selections from 4 bins resulted in the
following observed frequencies:
Bin
1
2
3
4
Obs. Freq.
10
5
10
7
As in the example in the previous section, suppose the null
hypothesis is:
H0 : p1 = 5/32, p2 = 11/32, p3 = 11/32, p4 = 5/32.
Example 1
The observed and expected frequencies are:
Bin
1
2
3
4
Obs. Freq.
10
5
10
7
Exp. Freq.
5
11
11
5
The value of the test-statistic is
d2 =
(10 − 5)2 (5 − 11)2 (10 − 11)2 (7 − 5)2
+
+
+
≈ 9.163.
5
11
11
5
The p-value is
p = P(D 2 ≥ 9.163) = χ2 cdf(9.163, 1E 99, 3) ≈ 0.0272,
so the null hypothesis is (once again) rejected.
Example 2: Test for Normality
The grades of students in a class of 200 are given in the following
table. Test the hypothesis that the grades are normally distributed
with a mean of 75 and a standard deviation of 8.
Range
Count
0-59
12
60-69
36
70-79
90
80-89
44
90-100
18
To compute the expected proportions, we use correction for
continuity:
I
P(X ≤ 59.5) = normalcdf(−1E 99, 59.5, 75, 8) = 0.0262,
I
P(59.5 ≤ X ≤ 69.5) = normalcdf(59.5, 69.5, 75, 8) = 0.2189,
I
P(69.5 ≤ X ≤ 79.5) = normalcdf(69.5, 79.5, 75, 8) = 0.4722,
I
P(79.5 ≤ X ≤ 89.5) = normalcdf(79.5, 89.5, 75, 8) = 0.2476,
I
P(89.5 ≤ X ) = normalcdf(89.5, 1E 99, 75, 8) = 0.0351.
Example 2: Test for Normality
The expected frequencies are:
I
E1 = (0.0262)(200) = 5.24,
I
E2 = (0.2189)(200) = 43.78,
I
E3 = (0.4722)(200) = 94.44,
I
E4 = (0.2476)(200) = 49.52,
I
E5 = (0.0351)(200) = 7.02.
The value of the test statistic is
D2 =
(12 − 5.24)2 (36 − 43.78)2 (90 − 94.44)2
+
+
5.24
43.78
94.44
(44 − 49.52)2 (18 − 7.02)2
+
+
= 26.22.
49.52
7.02
Example 2: Test for Normality
The p-value is
P(D 2 ≥ 26.22) = χ2 cdf(26.22, 1E 99, 4) = 2.857 · 10−5 .
Since the p-value is less than 5%, we reject H0 .
Conclusion: There is significant evidence that the data do not
follow a normal distribution with mean 75 and standard deviation 8
(χ2 = 26.22, df = 4, p < 0.001).
Case II: Parameters Unknown
Theorem 10.4.1
Let Y = Y (θ1 , θ2 , . . . , θs ) be a categorical random variable with
levels {y1 , y2 , . . . , yk } and let p̂i = P(Y = yi ) be the probabilities
if the parameters θi are replaced by their maximum
likelyhood estimates θ̂i . Suppose the probability experiment of
selecting one of the levels of Y is repeated independently n times.
Let Xi be the random variable that gives the number of times the
i-th level of Y is selected (the observed count), and let np̂i be
the expected count. Then, if n is large, the random variable
k
X
(Xi − np̂i )2
D =
np̂i
2
i=1
has approximately a chi-square distribution with k − s − 1 degrees
of freedom.
Example 2: Test for Normality
Consider again the grades of students. Test the hypothesis that
the grades are normally distributed.
The MLE for the mean is µ̂ = 76 and the MLE for the variance is
σ̂ 2 = 100 (computed from the original data). The observed counts
are as before:
Range
Count
0-59
12
60-69
36
70-79
90
80-89
44
90-100
18
We compute the expected proportions as before:
I
P(X ≤ 59.5) = normalcdf(−1E 99, 59.5, 76, 10) = 0.0494,
I
P(59.5 ≤ X ≤ 69.5) = normalcdf(59.5, 69.5, 76, 10) = 0.2084,
I
P(69.5 ≤ X ≤ 79.5) = normalcdf(69.5, 79.5, 76, 10) = 0.3790,
I
P(79.5 ≤ X ≤ 89.5) = normalcdf(79.5, 89.5, 76, 10) = 0.2747,
I
P(89.5 ≤ X ) = normalcdf(89.5, 1E 99, 75, 8) = 0.0885.
Example 2: Test for Normality
The expected frequencies are:
I
E1 = (0.0494)(200) = 9.89,
I
E2 = (0.2084)(200) = 41.67,
I
E3 = (0.3790)(200) = 75.80,
I
E4 = (0.2747)(200) = 54.93,
I
E5 = (0.0885)(200) = 17.70.
The value of the test statistic is D 2 = 6.063 and the p-value is
p = 0.194, so now we do not reject the hypothesis of having a
normal distribution with parameters µ = 76 and σ = 10.
Practice Problems for Section 10.3
I
p.508-509: 10.3.7, 10.3.9;
I
p.517-518: 10.4.1, 10.4.3.
Related documents