Chi-square goodness of fit test
The Chi-Square Goodness of Fit Test
The chi-square goodness of fit test is a statistical hypothesis test used to determine if an observed frequency distribution of a single categorical variable differs significantly from an expected frequency distribution. This test is frequently applied in situations where we have a theory or a prior expectation about how proportions should be distributed across different categories.
Hypotheses
Like all hypothesis tests, the chi-square goodness of fit test begins with stating null and alternative hypotheses:
- Null Hypothesis (H₀): The observed distribution of the categorical variable fits the hypothesized (expected) distribution. In other words, there is no significant difference between the observed and expected proportions in each category. This can be stated as p₁ = P₁, p₂ = P₂, ..., pₖ = Pₖ, where pᵢ are the true population proportions and Pᵢ are the hypothesized proportions.
- Alternative Hypothesis (Hₐ): The observed distribution does not fit the hypothesized distribution. At least one of the true population proportions is different from its hypothesized value.
Conditions for the Test
Before conducting the chi-square goodness of fit test, certain conditions must be met to ensure the validity of the results:
- Random Sample: The data must come from a random sample or a randomized experiment. This ensures the sample is representative of the population.
- Independence: Individual observations must be independent of each other. This means the outcome for one observation does not influence the outcome for another.
- Expected Counts: All expected counts must be at least 5. This condition is crucial because the chi-square distribution is a continuous distribution used to approximate the discrete distribution of the chi-square test statistic. This approximation is reliable only when expected counts are sufficiently large. If an expected count is less than 5, categories may need to be combined if logically sensible.
Calculating the Chi-Square Test Statistic
The chi-square (χ²) test statistic quantifies the discrepancy between the observed and expected frequencies. The formula is:
χ² = Σ [(Observed - Expected)² / Expected]
Where:
- Observed (O): The actual count of observations in each category from the sample data.
- Expected (E): The count that would be expected in each category if the null hypothesis were true. Expected counts are calculated as (sample size × hypothesized proportion for that category).
A larger χ² value indicates a greater discrepancy between observed and expected frequencies, providing stronger evidence against the null hypothesis.
Degrees of Freedom and P-value
The degrees of freedom (df) for a chi-square goodness of fit test are calculated as (number of categories - 1). This value determines the specific chi-square distribution used to find the P-value.
The P-value is the probability of observing a chi-square test statistic as extreme as, or more extreme than, the one calculated from the sample data, assuming the null hypothesis is true. A small P-value (typically less than the significance level α, e.g., 0.05) leads to the rejection of the null hypothesis, suggesting that the observed distribution significantly differs from the expected distribution.
Example Application
Imagine a genetics experiment where a theoretical model predicts offspring colors in a 9:3:3:1 ratio. We observe 560 offspring and count the frequencies of each color. To test if the observed distribution fits the theoretical ratio, we would use a chi-square goodness of fit test. We would calculate the expected counts for each color based on the 9:3:3:1 ratio and the total sample size of 560, then compute the chi-square statistic and find the P-value.
Practice questions
What is the primary purpose of the chi-square goodness of fit test?
Which condition is critical for the validity of a chi-square goodness of fit test, particularly regarding expected counts?
How are the degrees of freedom calculated for a chi-square goodness of fit test with 'k' categories?
A researcher hypothesizes that 20% of a city's residents prefer public transportation, 50% prefer personal cars, and 30% prefer ridesharing. If 200 residents are surveyed, what is the expected count for residents who prefer public transportation?
Related topics
Free AP4U account — unlimited practice, AI grader, and progress tracking.
Canonical: https://apforu.com/ap/statistics/unit-8-inference-for-categorical-data-chi-square/chi-square-goodness-of-fit-test