Degrees of Freedom in Goodness of Fit
You'll learn how to calculate degrees of freedom for chi-squared goodness of fit tests — the key to finding the right critical value.
The Core Idea
When you perform a chi-squared goodness of fit test, you need to know the degrees of freedom (df) to determine whether your test statistic is significant. The formula is straightforward:
df = (number of categories) - 1 - (number of estimated parameters)
Let's break this down:
- Number of categories: How many distinct groups or bins your data falls into
- Subtract 1: Because once you know the counts for all but one category, the last one is determined (they must sum to your total sample size)
- Subtract estimated parameters: If you had to estimate any population parameters from your data (like a mean or proportion), you lose additional degrees of freedom
Why This Matters
Think of degrees of freedom as the number of values that are "free to vary" in your calculation. If you have 5 categories and know 4 of them, the 5th is locked in. That's where the "-1" comes from.
The parameter penalty matters when you're testing fit to a distribution whose parameters you estimated from the same data. For example, if you're testing whether data fits a normal distribution and you calculated the mean and standard deviation from your sample, you'd subtract 2 more degrees of freedom.
Common Examples
- Testing if a die is fair (6 categories, no estimated parameters): df = 6 - 1 - 0 = 5
- Testing favorite colors (4 categories, no parameters): df = 4 - 1 - 0 = 3
- Testing fit to a Poisson distribution (k categories, estimated λ from data): df = k - 1 - 1 = k - 2
Key Takeaway: Degrees of freedom for goodness of fit equals the number of categories minus one, minus any parameters you estimated from the data — this determines which chi-squared distribution you'll use for your test.