Tutorials › VEE Mathematical Statistics › Degrees of Freedom With Fitted Goodness-of-Fit Parameters

VEE Mathematical Statistics · Classical Tests and Goodness of Fit · Tutorial 687 of 880

Degrees of Freedom With Fitted Goodness-of-Fit Parameters

Determine the correct chi-square degrees of freedom when a goodness-of-fit model has parameters estimated from the data.

Intermediate 10 min read

What You'll Learn

  • Apply the degrees-of-freedom rule for a fitted Pearson goodness-of-fit model
  • Count independent parameters rather than parameter labels
  • Distinguish same-sample estimates from values fixed externally
  • Calculate fitted expected counts and a Pearson statistic
  • Recognize when the standard degrees-of-freedom adjustment needs additional care

Why Fitting Parameters Changes the Reference Distribution

A Pearson goodness-of-fit test compares observed category counts with counts expected under a probability model. When the model probabilities are fully specified before the tested sample is observed, the reference chi-square distribution has one degree of freedom for each independent count deviation. If some model parameters are estimated from that same sample, the fitted probabilities have already adapted to the data. The test then has fewer independent directions in which the observed counts can differ from the fitted model.

The practical adjustment is simple, but it depends on counting correctly: start with the number of categories minus one, then subtract the number of independently estimated model parameters. The parameter count is not the number of symbols written in a model; it is the number of free quantities estimated from the sample being tested.

Definition: For a Pearson goodness-of-fit test with \(k\) categories and a regular model having \(r\) independently estimated parameters, the conventional degrees of freedom are $$ \nu = k-1-r. $$ This rule applies when the parameters are fitted from the same sample under the usual regularity conditions for the Pearson chi-square approximation. If all category probabilities were specified in advance, \(r=0\) and \(\nu=k-1\). A parameter estimated from an independent source is not counted as fitted from the tested sample in this conventional calculation.

Counting Independent Parameters

The subtraction is made after accounting for the fact that category probabilities sum to one. For \(k\) categories, only \(k-1\) count deviations can vary independently: once the first \(k-1\) counts are known, the last is determined by the fixed total sample size. Thus, the “minus one” is already present before any model parameter is fitted.

Next count the independent parameters estimated using the sample under test. For example, a binomial model with known number of trials and unknown success probability has one fitted parameter, \(p\). A model with two unknown normal parameters, \(\mu\) and \(\sigma\), has two. If parameters are constrained by a relationship, count the free parameters after applying the constraint. For instance, probabilities \(p_1,p_2,p_3\) satisfying \(p_1+p_2+p_3=1\) have two free values, not three.

Do not subtract a parameter merely because it appears in the model. A parameter fixed in advance, or set using independent historical data, was not adapted to the current sample’s category counts. Conversely, a parameter estimated from the tested observations is generally counted even if the estimate was computed from the raw observations rather than directly from the grouped counts. The conventional rule assumes a regular model and a fitting method for which the usual Pearson chi-square approximation applies; unusual fitting procedures or boundary estimates may require a different analysis.

Why the Adjustment Has This Form

A short dimension argument explains the formula. Let \(O_j\) be the observed count and \(E_j\) the fitted expected count in category \(j\), for \(j=1,\ldots,k\). Their deviations are \(O_j-E_j\). Because the observed and expected totals are both \(n\),

$$ \sum_{j=1}^{k}(O_j-E_j)=n-n=0. $$

This total constraint leaves \(k-1\) independent deviations before fitting. Estimating a model parameter uses the sample to adjust the fitted probabilities in a direction associated with that parameter. Under the standard regularity conditions, fitting \(r\) independent parameters removes \(r\) additional directions from the residual variation tested by the Pearson statistic. The remaining dimension is \(k-1-r\), which is the degrees of freedom of the approximate chi-square reference distribution.

This is a justification of the conventional result, not a claim that every parameter-fitting method automatically produces that reference distribution. In standard exam problems, use the stated model and the usual fitted-parameter rule unless the problem signals a nonstandard estimation method.

Worked Applications

Worked Example: Estimating the Probability in a Binomial Model

A hypothetical device is tested 100 times, with two trials per test. The number of successes in each test is recorded as 0, 1, or 2. The observed category counts are 20, 50, and 30. Test the binomial model’s degrees of freedom after estimating its success probability from these same observations. Also calculate the Pearson statistic.

Method and model. Let \(X\) be the number of successes in a test. Assume independent Bernoulli trials with a common success probability \(p\), so \(X\sim\operatorname{Binomial}(2,p)\). Estimate \(p\) from the total number of successes divided by the total number of Bernoulli trials.

There are \(50+2(30)=110\) observed successes among \(2(100)=200\) trials, so

$$ \hat p=\frac{110}{200}=0.55,\qquad 1-\hat p=0.45. $$

The fitted category probabilities are

$$ \begin{aligned} P(X=0)&=(0.45)^2=0.2025,\\ P(X=1)&=2(0.55)(0.45)=0.4950,\\ P(X=2)&=(0.55)^2=0.3025. \end{aligned} $$

Multiplying each probability by \(n=100\), the expected counts are \(20.25\), \(49.50\), and \(30.25\). They sum to \(20.25+49.50+30.25=100\), as required. The statistic is

$$ \begin{aligned} \chi^2 &=\frac{(20-20.25)^2}{20.25} +\frac{(50-49.50)^2}{49.50} +\frac{(30-30.25)^2}{30.25}\\ &=\frac{0.0625}{20.25} +\frac{0.25}{49.50} +\frac{0.0625}{30.25}\\ &\approx 0.003086+0.005051+0.002066\\ &\approx 0.0102. \end{aligned} $$

There are \(k=3\) categories and one independently estimated parameter, \(p\). Therefore

$$ \nu=3-1-1=1. $$

Check. The fitted probabilities sum to \(0.2025+0.4950+0.3025=1\), the expected counts sum to 100, and the model has exactly one free fitted parameter. The degrees of freedom are 1. The common mistake is to use \(3-1=2\) and forget that \(p\) was estimated from the tested sample.

Worked Example: Two Parameters Fitted in a Grouped Normal Model

A hypothetical sensor’s 200 readings are assigned to five fixed intervals. The model is normal, and both the mean and standard deviation are estimated from these same 200 readings. At the fitted values, the interval probabilities are \(0.10, 0.20, 0.40, 0.20, 0.10\). The observed counts are \(18, 43, 76, 42, 21\). Find the expected counts, Pearson statistic, and degrees of freedom.

Method and model. Assume the readings follow a normal distribution with unknown \(\mu\) and \(\sigma\), fitted from the sample. The five interval boundaries are fixed; the given probabilities are the probabilities assigned to those intervals at the fitted parameter values.

The expected counts are \(200\) times the respective probabilities:

$$ (E_1,E_2,E_3,E_4,E_5) =(20,40,80,40,20). $$

They sum to \(20+40+80+40+20=200\), matching the observed total \(18+43+76+42+21=200\). The Pearson statistic is

$$ \begin{aligned} \chi^2 &=\frac{(18-20)^2}{20} +\frac{(43-40)^2}{40} +\frac{(76-80)^2}{80} +\frac{(42-40)^2}{40} +\frac{(21-20)^2}{20}\\ &=\frac{4}{20}+\frac{9}{40}+\frac{16}{80}+\frac{4}{40}+\frac{1}{20}\\ &=0.200+0.225+0.200+0.100+0.050\\ &=0.775. \end{aligned} $$

There are five categories and two independently estimated parameters, \(\mu\) and \(\sigma\). Hence

$$ \nu=5-1-2=2. $$

Check. The observed and expected totals both equal 200, and the five contributions add to 0.775. The degrees of freedom are 2. Counting only \(\mu\), or counting a third parameter because the normal model also has a variance, would be incorrect: the fitted standard deviation corresponds to the single scale parameter \(\sigma\), not an additional parameter beyond it.

Worked Example: A Parameter Fixed From an Independent Source

A hypothetical calibration study established a fixed probability of \(0.25\) for an event. In a separate sample of 80 units, each unit is classified into one of four categories with prespecified probabilities \(0.25, 0.25, 0.25, 0.25\). The observed counts are \(18, 22, 17, 23\). Determine the expected counts, Pearson statistic, and degrees of freedom. Explain whether the calibration probability changes the degrees of freedom.

Method and model. Treat all four probabilities as fixed for this test; none is estimated from the 80 units being tested. The expected count in each category is \(80(0.25)=20\). The expected counts sum to \(4(20)=80\), as do the observed counts.

$$ \begin{aligned} \chi^2 &=\frac{(18-20)^2}{20} +\frac{(22-20)^2}{20} +\frac{(17-20)^2}{20} +\frac{(23-20)^2}{20}\\ &=\frac{4+4+9+9}{20} =\frac{26}{20}=1.30. \end{aligned} $$

There are four categories and zero parameters estimated from the current sample, so \(\nu=4-1-0=3\). The independently established calibration value is treated as fixed in this conventional calculation; it does not consume a degree of freedom from the tested sample. Check. The four observed counts total 80, the expected counts total 80, and the contributions sum to 1.30. A common mistake is subtracting one simply because a probability was estimated somewhere; the relevant distinction is whether it was fitted using the sample under test.

A Reliable Counting Procedure

1
Identify the categories.
Count the mutually exclusive categories included in the test. Call this number \(k\), and confirm the model assigns probabilities across those categories that sum to one.
2
Start with \(k-1\).
The fixed total count means that only \(k-1\) category-count deviations can vary independently.
3
Count free parameters fitted from this sample.
Count independent estimated quantities, accounting for constraints. Do not count fixed parameters or values obtained from an independent source as fitted from the tested sample.
4
Subtract and check.
Use \(\nu=k-1-r\). If the result is zero or negative, the test does not have a useful positive residual degrees of freedom under this standard calculation; reconsider the category structure or model.

Common Exam Traps and Scope

  • Using \(k-1\) automatically. That is appropriate only when no model parameter is estimated from the tested sample. A same-sample estimate reduces the conventional degrees of freedom.
  • Counting parameter names instead of free parameters. A constraint can make several named quantities depend on fewer independent values. Count only the free parameters actually estimated.
  • Subtracting a fixed or external estimate. A value specified in advance or estimated from a separate source is not the same as a parameter fitted to the current sample. State clearly which information produced the estimate.
  • Using the wrong number of categories. The count \(k\) is the number of categories in the test after any categories have been combined, not the number of possible outcomes in an unobserved model description.
  • Assuming the rule is exact for every fitting method. The Pearson statistic’s chi-square reference distribution is an approximation, and the simple subtraction is the standard result under regular conditions and appropriate fitting. Special estimation methods, parameter boundary cases, or non-identifiable models can require a more careful reference distribution.

Correct degrees of freedom matter because they determine which chi-square reference distribution is used to assess the statistic. A correctly calculated Pearson statistic paired with the wrong degrees of freedom can lead to the wrong tail probability and an incorrect test conclusion. The standard calculation here is aligned with the SOA VEE Mathematical Statistics syllabus.

Check Your Understanding

For each problem, identify the number of categories, count only the relevant independent fitted parameters, and determine the conventional degrees of freedom.

  1. A model assigns probabilities to six categories. Two independent parameters are estimated from the same tested sample. What are the degrees of freedom? (Answer: \(6-1-2=3\) degrees of freedom.)
  2. A four-category model has one unknown rate parameter estimated from the tested sample. In a second analysis, the rate is instead supplied from an independent calibration sample. Give the degrees of freedom for each analysis. (Answer: Same-sample estimate: \(4-1-1=2\); independent fixed value: \(4-1=3\).)
  3. Counts are grouped into the four possible outcomes \(0,1,2,3\) for a binomial variable with three trials. The success probability is estimated from the observations being tested. How many categories and fitted parameters are there, and what are the degrees of freedom? (Answer: \(k=4\), \(r=1\), so \(4-1-1=2\) degrees of freedom.)
  4. A five-category model is described using three parameter symbols, but one parameter is fixed at twice another, and the remaining two free values are estimated from the current sample. What degrees of freedom should be used? (Answer: There are two independent fitted parameters, so \(5-1-2=2\) degrees of freedom.)
  5. A six-category model has probabilities determined by two independently estimated parameters from the same sample. The observed counts are \(12,18,25,20,15,10\). What is the sample size and the conventional degrees of freedom? (Answer: \(n=12+18+25+20+15+10=100\), and \(6-1-2=3\) degrees of freedom.)
Clinical Biostats