Chi-Squared Tests
➔goodness-of-fit test is used for 1 independent variable
➔x2 test of independence is used for 2 variables
The X2 Goodness-of-fit Test
➔an extension of the binomial test
◆ essentially testing if own probabilities matches expected set
➔comparing observed distribution to the expected distribution
◆ opposed to a single observation against the expected distribution
➔tests probability of observing specific number of frequencies for 2/more categories
◆ relative to expected frequency
◆ tests the extent to which an observed pattern of observations (frequencies)
conforms/fits the expected pattern
● how well do the observed frequencies “fit” with the expected frequencies
➔Example:A gas station owner believes an equal numberof customers prefer to buy gasoline on
every day of the week. A manager at the service station disagrees with the owner and claims that
the number of customers who prefer to buy gasoline on each day of the week varies. The owner
surveyed 739 customers over time to record each customer’s preferred day of the week. The data
are summarized in the table below.
Mon Tues Wed Thur Fri Sat Sun
Freq. 103 103 126 103 111 96 97
- the expected it the number of people surveyed divided by the number of days in the week
- = 105.5
➔x goodness-of-fit test is a non-parametric test (justadding frequencies)
2
◆ doesn’t rely on estimating population parameters
◆ doesn’t requiretypicalparametric assumptions
➔x2 goodness-of-fit test assumptions
◆ the IV consists of mutually exclusive and exhaustive categories
◆ independence of observations
● on observation only fits into one subject
○ i.e. a person that comes to the gas station on friday can’t go any other day
◆ expected frequencies for each category is 5/more
, ● due to the x2 statistics being calculated using frequencies (continuous measure)
and approximates continuous variable when N is large
○ small N = a weird chi-squared distribution
➔formula:∑(observed frequency - expected frequency)2 / expected frequency
◆ used for both goodness-of-fit and test of independence
◆ finding the difference between observed and expected because it shows how much the
observed deviates from the expected
● squared because would otherwise be 0
◆ divided by the expected frequency because it standardizes the difference between
observed|observed
● planned a dinner party expecting 5 guests, but 3 extra people show up is different
when you plan a house party for 80 and 3 extra people show up
➔the formula could also be rewritten using probabilities
◆ N∑(POi - PEi)2 / PEi
● POi = probabilities of observed
● PEi = probabilities of expected
● N = total number of observations
➔increase N increases the X2, increasing the likelihoodof reject the H0 (null)
◆ type 1 error
◆ hence the need for the equivalent of an effect size for X2
➔E = N/K = 739/7 = 105.57 (*don’t round, keep up to 4 decimal places for the exam)
➔X2 = [(103 - 105.57)2 / 105.57] + [(103 - 105.57)2 / 105.57] + [(126 - 105.57)2 / 105.57] +
[(103 - 105.57)2 / 105.57] + [(111 - 105.57)2 / 105.57]+ [(96 -105.57)2 / 105.57] [(97
-105.57)2 / 105.57]
◆ = 5.98
➔the calculated score will never be a negative (if it is a negative it usually means forgot to square)
◆ because this test is not around the mean and is one-tailed, the distribution will always be
on the positive side (still looking at whether the score falls within the 5% significance
range)
➔as number of groups being looked at increases, the critical value also increases
➔degree of freedom = k -1
◆ k= number of groups
➔goodness-of-fit test is used for 1 independent variable
➔x2 test of independence is used for 2 variables
The X2 Goodness-of-fit Test
➔an extension of the binomial test
◆ essentially testing if own probabilities matches expected set
➔comparing observed distribution to the expected distribution
◆ opposed to a single observation against the expected distribution
➔tests probability of observing specific number of frequencies for 2/more categories
◆ relative to expected frequency
◆ tests the extent to which an observed pattern of observations (frequencies)
conforms/fits the expected pattern
● how well do the observed frequencies “fit” with the expected frequencies
➔Example:A gas station owner believes an equal numberof customers prefer to buy gasoline on
every day of the week. A manager at the service station disagrees with the owner and claims that
the number of customers who prefer to buy gasoline on each day of the week varies. The owner
surveyed 739 customers over time to record each customer’s preferred day of the week. The data
are summarized in the table below.
Mon Tues Wed Thur Fri Sat Sun
Freq. 103 103 126 103 111 96 97
- the expected it the number of people surveyed divided by the number of days in the week
- = 105.5
➔x goodness-of-fit test is a non-parametric test (justadding frequencies)
2
◆ doesn’t rely on estimating population parameters
◆ doesn’t requiretypicalparametric assumptions
➔x2 goodness-of-fit test assumptions
◆ the IV consists of mutually exclusive and exhaustive categories
◆ independence of observations
● on observation only fits into one subject
○ i.e. a person that comes to the gas station on friday can’t go any other day
◆ expected frequencies for each category is 5/more
, ● due to the x2 statistics being calculated using frequencies (continuous measure)
and approximates continuous variable when N is large
○ small N = a weird chi-squared distribution
➔formula:∑(observed frequency - expected frequency)2 / expected frequency
◆ used for both goodness-of-fit and test of independence
◆ finding the difference between observed and expected because it shows how much the
observed deviates from the expected
● squared because would otherwise be 0
◆ divided by the expected frequency because it standardizes the difference between
observed|observed
● planned a dinner party expecting 5 guests, but 3 extra people show up is different
when you plan a house party for 80 and 3 extra people show up
➔the formula could also be rewritten using probabilities
◆ N∑(POi - PEi)2 / PEi
● POi = probabilities of observed
● PEi = probabilities of expected
● N = total number of observations
➔increase N increases the X2, increasing the likelihoodof reject the H0 (null)
◆ type 1 error
◆ hence the need for the equivalent of an effect size for X2
➔E = N/K = 739/7 = 105.57 (*don’t round, keep up to 4 decimal places for the exam)
➔X2 = [(103 - 105.57)2 / 105.57] + [(103 - 105.57)2 / 105.57] + [(126 - 105.57)2 / 105.57] +
[(103 - 105.57)2 / 105.57] + [(111 - 105.57)2 / 105.57]+ [(96 -105.57)2 / 105.57] [(97
-105.57)2 / 105.57]
◆ = 5.98
➔the calculated score will never be a negative (if it is a negative it usually means forgot to square)
◆ because this test is not around the mean and is one-tailed, the distribution will always be
on the positive side (still looking at whether the score falls within the 5% significance
range)
➔as number of groups being looked at increases, the critical value also increases
➔degree of freedom = k -1
◆ k= number of groups