Chi Square Tests
Chi-square tests are hypothesis tests for categorical (count) data. They compare the frequencies you observed () with the frequencies you would expect () if the null hypothesis were true. Your Note 5 covers two types.
All chi-square tests use the same statistic:
If observed and expected counts are close, is small. If they differ a lot, is large, and you reject when it exceeds the critical value .
- Test of Association - Check if two random variables are significantly related
- Goodness of Fit test - Check if the chosen sample comes from a selected distribution
1. Test of association (independence)
Use it when: you have two categorical variables from the same population and want to know whether they are related.
Hypotheses:
- : there is no relationship between the variables.
- : there is a significant relationship between them.
Expected frequency under :
Degrees of freedom:
2. Goodness-of-fit test
Use it when: you want to check whether data follow a specific distribution, such as Uniform or Poisson.
Hypotheses:
- : the data do not follow the stated distribution.
- : the data follow the stated distribution.
Here comes from the distribution you are testing. The degrees of freedom are
- - No. of categories after merging
- - number of parameters estimated from the data like for poisson distribution if a parameter is not stated in and its estimated from data, we lose a degree of freedom
Worked example (digits, Example 1 in your notes)
From a list of 500 digits the occurrence of each distinct digit is observed. Test at 5% significance level, whether the sequence is a random sample from the Uniform distribution.
If the 500 digits are Uniform, each digit is expected times.
With , the critical value is . Here we do not lose DoF to since no parameters are derived from data that's not stated in
Since , reject . The digits do not appear to be a random sample from a Uniform distribution.
Steps for any chi-square test
- State and .
- Compute the expected frequencies .
- Compute .
- Find and the critical value (or the p-value).
- Decide: reject if .
- State the conclusion in context.
The test is only reliable when expected counts aren't too small. A common rule of thumb is in each cell. If some cells fall below that, combine categories.
When using Calc Spread Sheets for these, precompute some of the values and values to verify the formulas are working as expected. To reject the Null Hypothesis, we need the to be higher than the one for that confidence interval