Introduction: Comparing Theory to Reality
In actuarial work, we often start with a mathematical "guess" or a model. For example, we might assume that the number of insurance claims per day follows a Poisson distribution, or that male and female policyholders have the same likelihood of renewing their contracts. But how do we know if our assumptions are actually correct? This is where Chi-square (\(\chi^2\)) tests come in.
In this chapter, we will learn two powerful tools: the Goodness of Fit test (to check if data follows a specific distribution) and Contingency Tables (to check if two factors are independent of each other). These tests allow us to move from "I think this is the case" to "the statistical evidence suggests this is the case."
1. The Chi-square Goodness of Fit Test
The goal of a goodness of fit test is to determine if a set of observed data "fits" a theoretical probability distribution (like the Binomial, Poisson, or Normal distribution).
The Core Logic
We compare what we actually saw (Observed frequencies, \(O_i\)) with what we would expect to see if our theory were true (Expected frequencies, \(E_i\)).
If the difference between \(O_i\) and \(E_i\) is small, our theory is likely correct. If the difference is huge, our theory is probably wrong.
The Test Statistic
The standard test statistic is calculated as:
\( \chi^2 = \sum \frac{(O_i - E_i)^2}{E_i} \)
Where:
- \(O_i\) = Observed frequency for category \(i\)
- \(E_i\) = Expected frequency for category \(i\)
Step-by-Step Process
- State the Hypotheses:
\(H_0\): The data follows the specified distribution.
\(H_1\): The data does not follow the specified distribution. - Calculate Expected Frequencies: Multiply the total number of observations (\(n\)) by the probability of falling into that category (\(p_i\)). So, \(E_i = n \times p_i\).
- Check the "Rule of 5": For the Chi-square test to be valid, every expected frequency \(E_i\) should be at least 5. If an \(E_i\) is less than 5, you must group (combine) adjacent categories until the new combined \(E_i\) is 5 or more.
- Calculate the Statistic: Sum up \( \frac{(O_i - E_i)^2}{E_i} \) for all (potentially grouped) categories.
- Determine Degrees of Freedom (df): This is the most common place to lose marks!
\(df = k - 1 - p \)
where \(k\) is the number of categories (after grouping) and \(p\) is the number of parameters you had to estimate from the data to calculate the expected values. - Compare to Critical Value: If your calculated \(\chi^2\) is greater than the critical value from the tables at your significance level (usually 5%), you reject \(H_0\).
Top Tip: If the question gives you the parameters (e.g., "Test if this fits a Poisson distribution with \(\lambda = 2\)"), then \(p = 0\). If you have to calculate \(\lambda\) yourself from the data using the mean, then \(p = 1\).
2. Contingency Tables (Tests for Independence)
Actuaries often need to know if two categorical variables are related. For example, is "Smoker Status" (Smoker/Non-smoker) independent of "Policy Lapse" (Lapsed/Active)? We use a two-way contingency table to find out.
Hypotheses for Independence
\(H_0\): The two classification criteria are independent.
\(H_1\): The two classification criteria are not independent (there is an association).
Calculating Expected Frequencies in Tables
In a table with \(r\) rows and \(c\) columns, we calculate the expected frequency for each cell assuming independence:
\( E_{ij} = \frac{\text{Row } i \text{ Total} \times \text{Column } j \text{ Total}}{\text{Grand Total}} \)
Degrees of Freedom for Tables
For a contingency table, the degrees of freedom are always:
\(df = (r - 1) \times (c - 1) \)
Example: A \(3 \times 2\) table has \((3-1) \times (2-1) = 2 \times 1 = 2\) degrees of freedom.
Quick Review: Comparison Table
| Feature | Goodness of Fit | Contingency Table |
|---|---|---|
| Purpose | Does data fit a specific distribution? | Are two variables independent? |
| Degrees of Freedom | \(k - 1 - p\) | \((r - 1)(c - 1)\) |
| Grouping | Combine categories if \(E_i < 5\). | Combine rows/cols if \(E_{ij} < 5\). |
3. Important Practical Considerations
The "Rule of 5" and Grouping
If you have to combine categories because an expected value is too small, remember that this reduces your degrees of freedom.
Example: If you started with 6 categories (\(k=6\)) but had to combine the last two into one, your new \(k\) is 5. Your degrees of freedom calculation must use this new \(k\).
Interpretation of Results
If the calculated \(\chi^2\) is very small, it means the observed data is very close to what we expected. We fail to reject \(H_0\).
If the calculated \(\chi^2\) is very large, it means the "mismatch" is too big to be explained by random chance. We reject \(H_0\).
Did you know?
The Chi-square test is an approximate test. It becomes more accurate as the sample size increases. This is why we have the "Rule of 5"—it ensures the approximation is reliable enough for actuarial decision-making.
4. Common Mistakes to Avoid
- Forgetting to subtract estimated parameters: In Goodness of Fit tests, if you calculated the mean (\(\bar{x}\)) to use as \(\lambda\) for a Poisson distribution, you must subtract 1 from your degrees of freedom.
- Using \(O_i\) instead of \(E_i\) for the "Rule of 5": Only the expected frequencies matter for the grouping rule. It's okay if an observed frequency is less than 5.
- Calculation errors: It is very easy to make a typo when calculating \(\frac{(O-E)^2}{E}\). Always double-check your table of values.
- Wrong df for tables: Students often try to use \(n-1\) for contingency tables. Always use \((r-1)(c-1)\).
Key Takeaways Summary
1. Test Statistic: Always \( \sum \frac{(O-E)^2}{E} \).
2. Goodness of Fit df: \( (\text{Number of categories}) - 1 - (\text{Number of estimated parameters}) \).
3. Independence df: \( (r-1)(c-1) \).
4. Small Frequencies: Combine categories if \(E < 5\).
5. P-values: In Paper B (R), you will use the chisq.test() function, which handles these calculations for you and provides a p-value. If the p-value is less than \(\alpha\) (e.g., 0.05), reject \(H_0\).