Degrees of Freedom vs Chi-Square Test

Both terms below come up in the same part of the course, and students mix them up. Here is each one defined on its own, side by side, so you can see where they part company.

Degrees of freedom

Confidence intervals

Degrees of freedom count the independent pieces of information left after estimation, and they select which t or chi-square curve a statistic follows.

Degrees of freedom, written dfdf, count the independent pieces of information a statistic has left after some are spent estimating other quantities. Make that concrete. Four measurements with a sample mean of 10 must total 40. Pick the first three freely, say 7, 12, and 6, and the fourth is forced: 4025=1540 - 25 = 15. Three values were free, so df=3=n1df = 3 = n - 1.

The count matters because it selects the curve that sets the multiplier. A one-sample tt interval at 95% uses tt^* at n1n - 1 degrees of freedom: 2.262 when n=10n = 10, 2.064 when n=25n = 25, and 1.984 when n=100n = 100. Same level, three multipliers, differing only in how much information ss carries. All approach z=1.960z^* = 1.960 from above without arriving.

n1n - 1 is not a universal rule. A paired tt uses one fewer than the number of pairs, not of measurements. A chi-square test on an rr by cc table uses (r1)(c1)(r-1)(c-1), which depends on the shape of the table, not the sample size: a 2 by 3 table carries 2 degrees of freedom whether the counts total 60 or 6000.

Two habits cause most of the damage. One is reading the table at row nn: a sample of 20 has 19 df and t=2.093t^* = 2.093, while row 20 gives 2.086. The other is expecting a whole number: Welch's two-sample tt with s1=6s_1 = 6, n1=12n_1 = 12, s2=10s_2 = 10, and n2=15n_2 = 15 returns df=23.40df = 23.40. Nothing is counted there: it is the tt curve that best approximates a statistic whose distribution is not tt, and that density exists for any positive dfdf.

The Welch value is penned in by min(n11,n21)dfn1+n22\min(n_1 - 1, n_2 - 1) \le df \le n_1 + n_2 - 2, so 23.40 must land between 11 and 25, a fast data entry check. A calculator reports the decimal; a printed table forces a whole row, so round down. tt^* is 2.069 at 23 df against 2.067 at 23.40, so the interval comes out slightly wide, not falsely narrow.

Full entry for degrees of freedom

Chi-square test

Hypothesis testing

A chi-square test compares observed counts of categorical data to the counts expected under a hypothesis, gauging how far the data stray from that model.

A chi-square test asks whether a table of counts sits further from a model than sampling variability explains. Every version computes χ2=(OE)2E\chi^2 = \sum \frac{(O - E)^2}{E} across the cells, where OO is an observed count and EE the expected count under the null. Squaring throws away the direction of each gap, so every discrepancy pushes the statistic up instead of cancelling another, and all the evidence against the null lives in the upper tail of the chi-square curve.

Two schools are surveyed about biking to school: School A has 45 bikers out of 100, School B 45 out of 140. The expected counts from the margins are 37.5 and 62.5 in the first row, 52.5 and 87.5 in the second, so the four terms are 1.5, 0.9, 1.0714, and 0.6429. That gives χ2=4.1143\chi^2 = 4.1143 on (21)(21)=1(2 - 1)(2 - 1) = 1 degree of freedom, and a p-value of 0.0425. At α=0.05\alpha = 0.05 that is convincing evidence the two schools differ in their biking rates.

The error that ruins the test: "School A bikes at 45 percent and School B at 32.1 percent, so those go in the formula." Percentages are not counts, and χ2\chi^2 scales with how much data stands behind it. Double both schools while holding those two percentages fixed and the statistic doubles to 8.2286 with a p-value of 0.0041. Raw counts carry the sample size; percentages discard it.

Three tests share the formula and differ in where EE comes from and how the degrees of freedom are counted. Homogeneity compares separate samples on one categorical variable, which is the table above. Independence takes one sample and cross-classifies it two ways. Both read EE off the margins and use (r1)(c1)(r - 1)(c - 1) degrees of freedom. Goodness of fit checks one variable against claimed proportions using E=np0E = np_0.

Homogeneity and independence are AP Statistics topics 3.14 and 3.15. Goodness of fit was removed from the course for Fall 2026, so it is not examinable, though it stays standard in a college introductory course.

Full entry for chi-square test

Where each one fits in the course