LU 4 Lecture Notes

📚 LU 4 Lecture Notes_copy.pdf

Brief overview

This document introduces Chi-squared hypothesis tests, fundamental tools for analyzing categorical data. Understanding these tests is crucial for determining relationships and distributions within datasets.

Key points

  • Introduction to the Chi-squared distribution and its properties
  • How to use the Chi-squared table for critical values
  • Overview of the Chi-squared goodness-of-fit test for single variables
  • The Chi-squared test of independence for analyzing associations between two variables
  • Detailed steps for conducting Chi-squared hypothesis tests

1. Introduction to Chi-Squared Hypothesis Tests

1.1 Understanding the Chi-squared distribution

The Chi-squared distribution (²) is a continuous distribution used in hypothesis testing. It is positively skewed and its shape depends on the degrees of freedom.

Chi-squared values are always positive. This distribution helps us compare observed frequencies with expected frequencies.

The Chi-squared table is key to finding critical values. It uses degrees of freedom and the significance level (alpha, ).

The table has critical values for upper tail areas.

Diagram illustrating the Chi-squared distribution and a table of critical values.

Chi-squared distribution: Right-skewed, always positive, depends on degrees of freedom.

1.2 Chi-squared goodness-of-fit tests

A Chi-squared goodness-of-fit test checks if a variable's observed distribution significantly differs from its expected distribution. The expected distribution can be:

  • Equal proportions across all categories.
  • Proportions that match a known distribution.

For these tests, each category must have an expected frequency of at least 5 4.

1.2.1 Steps for a Chi-squared hypothesis test

Hypothesis testing with Chi-squared follows a structured process.

  1. State Hypotheses: Define the null (H0H_0) and alternative (H1H_1) hypotheses.
  • For equal proportions: H0:π1=π2=⋯=πkH_0: \pi_1 = \pi_2 = \dots = \pi_k, H1:H_1: At least one proportion differs.
  • For a known distribution: H0:H_0: Distribution follows a known pattern, H1:H_1: At least one proportion differs 5.
  1. Identify Rejection Region: Use the significance level (α\alpha) and degrees of freedom (df=k−1df = k-1) to find the critical value from the ² table. kk is the number of categories.
  2. Calculate Test Statistic: Compute the ² test statistic using observed (fof_o) and expected (fef_e) frequencies.

χ2=∑(fo−fe)2fe\chi^2 = \sum \frac{(f_o - f_e)^2}{f_e}

  • Observed frequencies (fof_o) are the actual counts.
  • Expected frequencies (fef_e) are calculated as n×πin \times \pi_i, where nn is the total sample size and πi\pi_i is the expected proportion for category ii 6.

Formula for calculating the chi-squared test statistic, which involves the sum of squared differences between observed and expected frequencies, divided by expected frequencies.

A table showing observed values, expected values, and a formula for calculating the chi-squared statistic.

  1. Make a Decision: Compare the test statistic to the critical value. Reject H0H_0 if the test statistic falls within the rejection region.
  2. Reach a Conclusion: Interpret the decision in the context of the problem. If H0H_0 is rejected, there is sufficient evidence to support H1H_1 7.

Test statistic: Sum of (Observed−Expected)2Expected\frac{(\text{Observed} - \text{Expected})^2}{\text{Expected}} for all categories.

1.2.2 Example: Taste test preferences

A company tested consumer preferences for 4 products (A, B, C, D) with 120 consumers. Preferences were: A=24, B=45, C=30, D=21.

Test at the 5% significance level for brand preference.

CategoryObserved (fof_o)Expected (fef_e)(fo−fe)2fe\frac{(f_o - f_e)^2}{f_e}
A2430(24−30)230=1.20\frac{(24-30)^2}{30} = 1.20
B4530(45−30)230=7.50\frac{(45-30)^2}{30} = 7.50
C3030(30−30)230=0.00\frac{(30-30)^2}{30} = 0.00
D2130(21−30)230=2.70\frac{(21-30)^2}{30} = 2.70
Total12012011.40
  • Hypotheses: H0:H_0: All proportions are equal (πA=πB=πC=πD=0.25\pi_A=\pi_B=\pi_C=\pi_D=0.25). H1:H_1: At least one proportion is different 8.
  • Degrees of freedom: df=4−1=3df = 4-1 = 3.
  • Critical value: At α=0.05\alpha=0.05 and df=3df=3, the critical value is 7.8157.815 9.
  • Test statistic: χ2=11.40\chi^2 = 11.40.
  • Decision: Since 11.40>7.81511.40 > 7.815, reject H0H_0.
  • Conclusion: There is sufficient evidence of brand preference.
  • The p-value is 0.00980.0098. This means there is a 0.98%0.98\% chance of observing such extreme results if there were no brand preference 11.

This test helps determine if observed counts in categories differ from what's expected by chance.

1.2.3 Example: Changing market share

A company's cold drink brands (A, B, C) historically had market shares of 50% (A), 30% (B), and 20% (C). Recent sales: A=130, B=75, C=35 units.

Test at the 10% significance level.

CategoryObserved (fof_o)Expected (fef_e)(fo−fe)2fe\frac{(f_o - f_e)^2}{f_e}
A130120(130−120)2120=0.83\frac{(130-120)^2}{120} = 0.83
B7572(75−72)272=0.13\frac{(75-72)^2}{72} = 0.13
C3548(35−48)248=3.52\frac{(35-48)^2}{48} = 3.52
Total2402404.48
  • Hypotheses: H0:H_0: Distribution is 50% A, 30% B, 20% C. H1:H_1: At least one proportion is different 12.
  • Degrees of freedom: df=3−1=2df = 3-1 = 2.
  • Critical value: At α=0.10\alpha=0.10 and df=2df=2, the critical value is 4.6054.605.
  • Test statistic: χ2=4.48\chi^2 = 4.48.
  • Decision: Since 4.48<4.6054.48 < 4.605, fail to reject H0H_0.
  • Conclusion: There is insufficient evidence to suggest the market share distribution has changed.
  • The p-value is 0.10650.1065. This means there is a 10.65%10.65\% chance of observing these sales figures if the historical market shares were still true 15.

When interpreting p-values, remember: p-value <  leads to rejecting H0.

🔑 Important: The Chi-squared distribution's critical value is found using degrees of freedom and the significance level13.

📝 Example: A small expected frequency (less than 5) in any category invalidates the Chi-squared test.


🔑 Important: For Chi-squared goodness-of-fit tests, the test statistic is always positive and the rejection region is always in the right tail 2 3.

2. Chi-squared test of independence

2.1 Purpose and hypotheses

The Chi-squared test of independence assesses if there's a relationship between two categorical variables. It uses data from a contingency table, which cross-tabulates the levels of the two variables.

The null hypothesis (H0H_0) states that the variables are independent. The alternative hypothesis (H1H_1) states that they are dependent.

  • Null hypothesis (H0H_0): The two variables are independent, unrelated, or not associated.
  • Alternative hypothesis (H1H_1): The two variables are dependent, related, or associated.

2.2 Calculating expected frequencies and the test statistic

Expected frequencies (fef_e) are calculated assuming the null hypothesis is true. They represent the frequencies you'd expect if the variables were independent.

A key requirement is that all expected frequencies must be at least 5. The test statistic measures the difference between observed (fof_o) and expected frequencies 18.

The formula for expected frequency for cell (i, j) is: fe(i,j)=(row i total)×(column j total)sample sizef_e(i, j) = \frac{(\text{row } i \text{ total}) \times (\text{column } j \text{ total})}{\text{sample size}}.

The Chi-squared test statistic is calculated as: χ2=∑(fo−fe)2fe\chi^2 = \sum \frac{(f_o - f_e)^2}{f_e}.

The formula for calculating the chi-squared test statistic involves summing the squared difference between observed and expected frequencies, divided by the expected frequencies.

2.3 Determining the critical value and making a decision

To find the critical value, you need the level of significance and the degrees of freedom (df). The degrees of freedom are calculated as df = (r – 1)(c – 1), where 'r' is the number of rows and 'c' is the number of columns in the contingency table.

You then compare this calculated test statistic to the critical value from a Chi-squared distribution table.

  • If the test statistic falls within the rejection region (i.e., it's greater than or equal to the critical value), you reject H0H_0.
  • If the test statistic falls outside the rejection region (i.e., it's less than the critical value), you fail to reject H0H_0.

A table displaying critical values for statistical tests based on degrees of freedom (df) and significance level (alpha).

🔑 Important: The distribution used for this test is a probability distribution, typically bell-shaped with a peak at the beginning and decreasing tails.

2.4 Drawing a conclusion and interpreting results

If you reject H0H_0, there is sufficient evidence to support the alternative hypothesis that the two variables are dependent. If you fail to reject H0H_0, there is insufficient evidence to claim the variables are dependent 19.

The following exercise illustrates these steps:

📝 Example: A study surveyed 60 city dwellers and 40 rural dwellers about a TV program. 35% of city dwellers liked it, and 22 rural dwellers liked it. At a 2.5% significance level, is opinion related to area of residence?

OpinionCity (observed)Rural (observed)Total
Like212243
Dislike391857
Total6040100
20 22.

Calculating expected frequencies:

  • Like, City: (60×43)/100=25.8(60 \times 43) / 100 = 25.8
  • Like, Rural: (40×43)/100=17.2(40 \times 43) / 100 = 17.2
  • Dislike, City: (60×57)/100=34.2(60 \times 57) / 100 = 34.2
  • Dislike, Rural: (40×57)/100=22.8(40 \times 57) / 100 = 22.8.
OpinionCity (observed/expected)Rural (observed/expected)
Like21 / (25.8)22 / (17.2)
Dislike39 / (34.2)18 / (22.8)
χ2=(21−25.8)225.8+(22−17.2)217.2+(39−34.2)234.2+(18−22.8)222.8\chi^2 = \frac{(21-25.8)^2}{25.8} + \frac{(22-17.2)^2}{17.2} + \frac{(39-34.2)^2}{34.2} + \frac{(18-22.8)^2}{22.8} χ2=(−4.8)225.8+(4.8)217.2+(4.8)234.2+(−4.8)222.8\chi^2 = \frac{(-4.8)^2}{25.8} + \frac{(4.8)^2}{17.2} + \frac{(4.8)^2}{34.2} + \frac{(-4.8)^2}{22.8} χ2=23.0425.8+23.0417.2+23.0434.2+23.0422.8\chi^2 = \frac{23.04}{25.8} + \frac{23.04}{17.2} + \frac{23.04}{34.2} + \frac{23.04}{22.8} χ2≈0.893+1.340+0.674+1.011≈3.918\chi^2 \approx 0.893 + 1.340 + 0.674 + 1.011 \approx 3.918 23.

Degrees of freedom: df = (2 - 1)(2 - 1) = 1. Critical value for α=0.025\alpha = 0.025 and df = 1 is approximately 5.024.

Since 3.918<5.0243.918 < 5.024, we fail to reject H0H_0 17 21.

The p-value for this test is 0.0478. This value is greater than the significance level of 0.025, further supporting the decision to fail to reject H0H_0.

🔑 Important: The p-value represents the probability of observing a test statistic as extreme as, or more extreme than, the one calculated, assuming the null hypothesis is true 24.

🔑 Important: The Chi-squared test of independence requires that expected frequencies are at least 5 to ensure the validity of the test 16.

🔑 Important: The key for the Chi-squared test of independence is comparing the calculated test statistic to the critical value. If the test statistic is larger, H0H_0 is rejected.

© 2026 Maeve. All rights reserved. This content is protected by copyright.

See also