Chi-Square Goodness-of-Fit Test
Study guides: VEE-MS, Exam ASTAM, Exam MAS-I, Exam ACIA-CAPSTONE
A Chi-Square Goodness-of-Fit Test is a hypothesis test of whether the counts of n observations in k categories agree with the probabilities p_1, \ldots, p_k that a hypothesized distribution assigns to the categories. The test statistic is
Q = \sum_{j=1}^{k} \frac{(O_j - n p_j)^2}{n p_j}
O_jis the observed count in categoryj, andO_1 + \cdots + O_k = n.n p_jis the expected count in categoryjunderH_0.
Under H_0, Q has approximately a chi-squared distribution with k - 1 degrees of freedom when the probabilities p_j are fully specified. Large differences between the observed and expected counts make Q large, so the test rejects H_0 at significance level \alpha when Q exceeds the upper \alpha point \chi^2_{\alpha,k-1}. The approximation needs every expected count to be at least 5, and sparse categories are combined until this holds.
A die is rolled 120 times, and the faces 1 to 6 come up 25, 17, 15, 23, 24 and 16 times. Does a test at significance level 0.05 reject the hypothesis that the die is fair?
- Under
H_0each face has probability1/6, so each expected count is120/6 = 20.- The squared differences from 20 are 25, 9, 25, 9, 16 and 16, which sum to 100.
- The test statistic is
Q = 100/20 = 5.0, with6 - 1 = 5degrees of freedom.- Because
5.0 < \chi^2_{0.05,5} = 11.07, the test does not reject the hypothesis that the die is fair.
Testing a fitted distribution
When the hypothesized distribution has r parameters estimated from the same data, one more degree of freedom is lost for each of them. The number of degrees of freedom of Q is then
k - 1 - r
Of 500 policies, 260 had no claims, 190 had one claim, 40 had two and 10 had three. Does a test at significance level 0.05 reject a Poisson model fitted by maximum likelihood, with the categories 0, 1, 2 and 3 or more?
- The maximum likelihood estimate is the sample mean,
\hat{\lambda} = \frac{190 + 80 + 30}{500} = 0.6.- The Poisson probabilities are 0.5488, 0.3293 and 0.0988, which leaves 0.0231 for 3 or more claims.
- The expected counts are 274.41, 164.64, 49.39 and 11.56.
- The terms
(O_j - n p_j)^2 / (n p_j)are 0.756, 3.905, 1.786 and 0.210, soQ = 6.66.- One parameter was estimated, so there are
4 - 1 - 1 = 2degrees of freedom and\chi^2_{0.05,2} = 5.991.- Because
6.66 > 5.991, the test rejects the Poisson model.
Test of independence in a contingency table
The same statistic tests whether two classifications of the n observations are independent. In a table with I rows and J columns, the expected count of the cell in row i and column j under independence is
\frac{(\text{row } i \text{ total})(\text{column } j \text{ total})}{n}
The statistic Q, summed over all IJ cells, is compared with a chi-squared distribution with (I - 1)(J - 1) degrees of freedom.
Of 200 urban policies, 30 had a claim, and of 300 rural policies, 20 had a claim. Does a test at significance level 0.05 reject the hypothesis that having a claim is independent of territory?
- The row totals are 200 and 300, the column totals are 50 with a claim and 450 without, and
n = 500.- The expected counts are
\frac{200 \times 50}{500} = 20and 180 for urban, and 30 and 270 for rural.- The terms are
\frac{(30 - 20)^2}{20} = 5.000, 0.556, 3.333 and 0.370, soQ = 9.26.- The table has
(2 - 1)(2 - 1) = 1degree of freedom, and\chi^2_{0.05,1} = 3.841.- Because
9.26 > 3.841, the test rejects independence.
Test for shifting risk parameters
To test whether a claim frequency is constant over m periods, the actual claim count of each period is compared with its expected claim count under a constant frequency. If period i has exposure w_i and A_i claims, the test statistic is
Q = \sum_{i=1}^{m} \frac{(A_i - w_i \lambda)^2}{w_i \lambda}
\lambdais the hypothesized claim frequency per unit of exposure, sow_i \lambdais the expected claim count of periodi.
The periods' counts are independent rather than fixed in total, so with a given frequency the statistic has m degrees of freedom. When the frequency is the overall mean estimated from the same data, it has m - 1. A statistic above the critical value rejects the null hypothesis that the frequency is not shifting.
Four years have exposures of 1,000, 1,200, 1,100 and 900 and claim counts of 52, 70, 48 and 30. Does a test at significance level 0.05 show that the claim frequency is shifting?
- The overall mean frequency is
\frac{200}{4{,}200} = 0.04762.- The expected counts are the exposures times 0.04762: 47.62, 57.14, 52.38 and 42.86.
- The terms are 0.403, 2.893, 0.366 and 3.857, so the statistic is 7.52.
- The frequency was estimated from the data, so there are
4 - 1 = 3degrees of freedom and\chi^2_{0.05,3} = 7.815.- Because
7.52 < 7.815, the test does not reject the hypothesis that the frequency is constant.
Forgetting the estimated parameters in the degrees of freedom In the Poisson example, comparing
Q = 6.66with\chi^2_{0.05,3} = 7.815, as if no parameter had been estimated, would keep a model that the test with 2 degrees of freedom rejects.