Chi-squared: Degrees of Freedom Explained with Worked Examples

For a contingency table with rows and columns, . For a goodness-of-fit test with categories and parameters estimated from the data, .

Write 2x or 2*x to multiply, ^ for powers, and ; between simultaneous equations. You can also type factor, expand, derivative of, integrate … from a to b, limit … as x->0 or 15% of 80.

Try an example

Before you start

What Chi-squared: degrees of freedom means

Degrees of freedom count the number of independent pieces of information. In an table with all row and column totals fixed, only cells can be chosen freely. For a table . The value of selects the row of the chi-squared table used to read the critical value; the statistic itself is in the chi-squared test statistic.

In a goodness-of-fit test, the frequencies must add to the total, which removes 1, and each parameter estimated from the data removes another. For 6 categories (a die) with no estimated parameter, . For a Poisson fit with 5 classes where is estimated from the data, ; see the Poisson distribution.

The tests are described in the chi-squared test of independence. A related count of "free" quantities appears in the t distribution with n − 1 degrees of freedom and in analysis of variance.

What is it used for?

The degrees of freedom count how many values in a table or fit can vary freely, and choose the critical value.

How to use chi-squared: degrees of freedom

  1. Decide whether it is a contingency table or a goodness-of-fit test.
  2. For a table, compute .
  3. For goodness of fit, compute , where is the number of estimated parameters.
  4. Use to look up the critical value.

Graph

Degrees of freedom: 3 × 4 table 6, fair die 5, Poisson fit with 5 classes 33 × 4 table: 6die: 5Poisson fit: 300.511.522.533.5401234567Degrees of freedom: 3 × 4 table 6, fair die 5, Poisson fit with 5 classes 3testyGraph with x from 0 to 4 and y from 0 to 7. Shows bars (3); point 3 × 4 table: 6 at (1, 6); point die: 5 at (2, 5); point Poisson fit: 3 at (3, 3).

More categories give more freedom; each fitted parameter takes one away.

Worked examples

These examples are worked by hand, step by step, so you can compare your own working.

Example 1: a 3 × 4 table

Find the degrees of freedom for a contingency table with 3 rows and 4 columns.

Worked example
Answer
66
  1. Formula

Example 2: a die

Find the degrees of freedom for testing whether a die with 6 faces is fair.

Worked example
Answer
55
  1. Formula

Example 3: a Poisson fit

A Poisson distribution is fitted to 5 classes, estimating from the data. Find the degrees of freedom.

Worked example
Answer
33
  1. Formula

Special cases

A few situations come up again and again. Knowing them saves time and helps you spot answers that cannot be right.

3 × 4 table

(r − 1)(c − 1)

6.

2 × 2 table

ν

1.

6 categories, 1 parameter estimated

n − 1 − m

4.

5 × 5 table

ν

16.

Word problems

Contingency table: ν = (r − 1)(c − 1). Goodness of fit: ν = n − 1 − m, where m parameters are estimated.

3 × 4

Rows and columns.

  1. 2 × 3
  2. Check: ✓6

2 × 2

Smallest table.

  1. 1 × 1
  2. Check: ✓1

Fit Higher

6 categories, 1 estimated parameter.

  1. 6 − 1 − 1
  2. Check: ✓4

5 × 5 Higher

Large table.

  1. 4 × 4
  2. Check: ✓16

Common mistakes

ν = rc

all cells ✗

(r − 1)(c − 1) ✓

Totals fixed.

Forgetting estimated parameters

n − 1 ✗

n − 1 − m ✓

Each costs one.

ν = n

n ✗

n − 1 ✓

Total fixed.

Counting totals as rows

include ✗

exclude totals ✓

Table size.

Exam tips

  1. Table: (r − 1)(c − 1).
  2. Fit: n − 1 − m.
  3. Exclude totals.
  4. Estimated parameters reduce ν.
  5. Use for the critical value.

Practice questions

Try each one on paper, then open the answer. Use the solver above to see the full working.

1. ν for a 4 × 3 table Foundation

6

2. ν for a 2 × 5 table Foundation

4

3. ν: 8 categories, 0 estimated Foundation

7

4. ν: 8 categories, 2 estimated Higher

5

5. ν for a 6 × 6 table Higher

25

6. ν: 4 categories, 1 estimated (Poisson) Higher

2

Practice generator

Unlimited fresh questions with instant marking. Choose a level, work it out on paper, then type your answer.

Solve: …

Key terms

Degrees of freedom
Free values.
Contingency table
r × c counts.
Goodness of fit
Compare to a model.
Parameter
Estimated from data.
Category
Class.
Critical value
From ν.

Frequently asked questions

How do I find ν for a contingency table?

(r − 1)(c − 1).

How do I find ν for goodness of fit?

n − 1 − m.

What is m?

The number of parameters estimated.

Why subtract 1?

The total is fixed.

Which page covers the statistic?

chi-squared statistic.

Which page covers independence?

chi-squared test of independence.

More in Advanced statistics and stochastic processes and the formula sheets.