Logo

Data Learning Center Statistical Guides

chi-sq-test.knit

The Chi-square (χ2) Test

 When our data includes two categorical variables, we can determine if there is a statistically significant relationship (or alternatively dependence) between them with the χ2 test. WIth the χ2 test, we compare the observed counts (our data) with the expected counts if the data came from the same distributions.

 For this tutorial we will use this data set from an example offered in STAT 500 Applied Statistics where participants were asked to give their party affiliation (Democrat or Republican) and their opinion on a tax reform bill (Favor, Indifferent, or Opposed).

Favor Indifferent Opposed
Democrat
138
83
64
Republican
64
67
84

 The researcher wants to know whether a relationship exists between party affiliation and opinion, which corresponds to the following statistical hypotheses:

H0: No relationship exists between party affiliation and opinion on the tax reform bill
HA: There is a significant relationship between party affiliation and opinion on the tax reform bill


 To test these hypotheses with a χ2 test we can first select Analyze -> Fit Y by X. Then in the pop-up window we can add Party and Position to the Y, Response and X, Factor boxes, respectively, then add Count to the Freq box. Note that the order of factors for the χ2 is not important, so if you chose to respectively switch Party and Position to the X, Factor and Y, Response boxes you will receive the same results. We can then select OK to run the χ2 test.

 From the results of the χ2 test, in the Tests table we can see that there is a statistically significant difference between how Democrats and Republicans view the proposed tax reform bill. If we wish to see exactly how our participants’ opinions differ between party lines we can click the red arrow next to Contingency Analysis of Party By Position then select Analysis of Means for Proportions.

 The above plot compares the proportion of Democrats who held each position compared to the average position, from which points outside the blue regions indicate statistically significant differences. We can conclude that the Democratic respondents overall had more respondents that chose Favor and fewer who chose Opposed regarding the tax bill compared to their Republican counterparts. There was not a statistically significant difference in the proportion of respondents that chose Indifferent between Democrat and Republican respondents.

DLC_statistical_guides