# Chi-Squared Tests Source: https://cca.twango.dev/AP-Statistics/chi-squared-tests # Chi-Squared Tests Chi-square tests compare observed and expected **counts**, not percentages. $$ \chi^2=\sum\frac{(O-E)^2}{E}. $$ Large statistics give evidence against $H_0$; use the upper-tail chi-square probability. ## Goodness of fit Use for one categorical variable in one sample. - $H_0$: category proportions equal the specified values $p_1,\ldots,p_k$, which sum to 1. Equal proportions are only one possible null model. - $H_a$: at least one category proportion differs from its specified value. - Expected counts: $E_i=np_i$. - Degrees of freedom: $k-1$ when the probabilities were specified beforehand and no parameters are fitted. > [!warning] Review correction > The original alternative said “at least $n$ proportions are wrong.” It should say **at least one** differs. ## Independence Use for two categorical variables measured on one sample. - $H_0$: the variables are independent in the population. - $H_a$: the variables are associated. $$ E_{ij}=\frac{(\text{row total})(\text{column total})}{\text{grand total}}, \qquad df=(r-1)(c-1). $$ ## Homogeneity Use to compare the distribution of one categorical variable across independent samples from multiple populations or treatment groups. - $H_0$: category proportions are the same across populations/groups. - $H_a$: the distributions are not all the same. The expected-count formula and degrees of freedom are the same as for independence; the sampling design differs. ## Conditions and conclusions Require an appropriate random sample or randomized design and independent observations. For the AP course rule, all expected cell counts should be at least 5. When sampling without replacement, check the 10% condition for approximate independence. A convenience sample is not made random merely by calling it representative. At the chosen significance level, reject $H_0$ if $p<\alpha$; otherwise **fail to reject**, without claiming proof of independence or equal distributions. Method reference: [NIST chi-square independence test](https://itl.nist.gov/div898/software/dataplot/refman1/auxillar/chistest.htm). Related: [[inference|Inference methods]] · [[S2-Final-Project/s2-report|Counting-project table corrections]]