Chi-square goodness-of-fit test
Goodness of fit and normality · reference distribution: χ²(k−1)
When to use it
Check whether the observed frequencies in categories match the ones a theory expects, such as a fair die.
Null hypothesis
The category proportions are the specified ones.
Assumptions
- Independent observations
- Expected frequencies of at least 5
Test statistic
\chi^2 = \sum_i \dfrac{(O_i - E_i)^2}{E_i}How to report it
χ²(5, N = 120) = 4.8, p = .44
In R and Python
R
chisq.test(observed, p = expected_proportions)
Python
stats.chisquare(observed, f_exp=expected)
In Python, stats is scipy.stats and np is numpy.
Where it sits in the catalog
Goodness of fit and normality. Goodness of fit: do the data follow the expected distribution? Normality tests are the most common case and check an assumption of parametric tests.
In the decision tree
- What do you want to do? Compare groups, or one group with a reference value
- What kind of response did you measure? Categorical: yes or no, or categories
- How many groups or measurements? One group, with several categories against expected frequencies
- What do you want to do? Check an assumption or the distribution of the data
- What do you want to check? Whether the category frequencies are the expected ones