Why Summarize Pearson Residuals?
A GLM can produce a fitted value for every observation without fitting the data equally well across all observations. The Pearson goodness-of-fit statistic condenses the discrepancies between observed and fitted responses into one number, scaling each discrepancy by the response variance expected under the model. Its degrees of freedom account for the parameters estimated from the same data.
The statistic is a diagnostic, not a substitute for examining individual residuals or the data structure. A value that appears large relative to its degrees of freedom can signal lack of fit, but it can also reflect an unsuitable variance assumption, dependence, or data that are too sparse for a reliable chi-square approximation.
This definition uses the model’s variance function, including any observation-specific weights or known exposure structure. For example, a Poisson response has \(V(\mu)=\mu\); a binomial count with \(m_i\) trials and success probability \(p_i\) has variance \(m_i p_i(1-p_i)\). These variances are different, so the same raw discrepancy can contribute differently under different response distributions.
When the variance is \(\operatorname{Var}(Y_i)=\phi V(\mu_i)\) with a scale parameter \(\phi\), the conventional unscaled statistic above divides by \(V(\hat{\mu}_i)\), not by \(\phi V(\hat{\mu}_i)\). If \(\phi\) is known and the goal is to form residuals scaled by the full variance, the squared scaled residuals sum to \(X_P^2/\phi\). For Poisson and binomial GLMs in their usual form, \(\phi=1\). Do not silently switch between these conventions.
From Pearson Residuals to the Statistic
The derivation follows directly from standardizing each response discrepancy. A raw residual \(y_i-\hat{\mu}_i\) is measured in the units of the response. Dividing by the square root of the fitted variance expresses that discrepancy in variance-standardized units. Squaring and summing gives a measure of total discrepancy on that scale:
For response row \(i\), use \(V(\hat{\mu}_i)\), with weights, trial counts, or other specified variance components included.
Set \(r_{P,i}=(y_i-\hat{\mu}_i)/\sqrt{V(\hat{\mu}_i)}\).
Since \(r_{P,i}^2=(y_i-\hat{\mu}_i)^2/V(\hat{\mu}_i)\), summing over rows gives \(X_P^2=\sum_i r_{P,i}^2\).
Compare the statistic with the residual degrees of freedom, usually the number of response rows minus the rank of the fitted model matrix.
The degrees-of-freedom adjustment has a geometric explanation. Under regularity conditions, the vector of standardized discrepancies is approximately projected away from the directions used to estimate the model parameters. If there are \(n\) response rows and the design matrix has rank \(q\), the remaining residual space has dimension \(n-q\). A quadratic form in that residual space is therefore approximately chi-square with \(n-q\) degrees of freedom when the mean and variance model are correct and the scale is one. This is an asymptotic approximation, not an exact identity for every finite sample.
Count response rows, not automatically the number of underlying trials, policy-years, or exposure units. In grouped binomial data, one row may represent many trials; the fitted variance for that row includes its trial count, while the degrees of freedom are based on the number of grouped response rows and model rank. Likewise, exposure affects a Poisson fitted mean through the model but does not create extra response rows. Use the rank of the design matrix, not merely the number of coefficient names: aliased or redundant columns do not increase the rank.
Worked Calculations
Worked Example: Grouped Binomial Frequency Fit
A hypothetical insurer fits a common claim probability to four independent groups. The group trial counts are 20, 40, 60, and 80, and the observed claim counts are 8, 14, 21, and 29. Assume each group count is binomial, \(Y_i\sim\operatorname{Binomial}(m_i,p)\), with a common probability \(p\), and no additional scale parameter. Calculate the Pearson statistic and residual degrees of freedom.
Method and fitted values. The maximum-likelihood estimate of the common probability is total claims divided by total trials: \( \hat p=(8+14+21+29)/(20+40+60+80)=72/200=0.36 \). The fitted counts are \(m_i\hat p\), giving \(7.2,\ 14.4,\ 21.6,\ 28.8\). For a binomial count, the fitted variance in group \(i\) is \(m_i\hat p(1-\hat p)\), and \(1-\hat p=0.64\).
Group 1. The variance is \(20(0.36)(0.64)=4.608\). The Pearson contribution is \((8-7.2)^2/4.608=0.64/4.608=0.1388889\).
Group 2. The variance is \(40(0.36)(0.64)=9.216\). The contribution is \((14-14.4)^2/9.216=0.16/9.216=0.0173611\).
Group 3. The variance is \(60(0.36)(0.64)=13.824\). The contribution is \((21-21.6)^2/13.824=0.36/13.824=0.0260417\).
Group 4. The variance is \(80(0.36)(0.64)=18.432\). The contribution is \((29-28.8)^2/18.432=0.04/18.432=0.0021701\).
Adding the contributions gives \(X_P^2=0.1388889+0.0173611+0.0260417+0.0021701=0.1844618\), or 0.1845 to four decimal places. There are four response rows and one estimated parameter, so \(\nu_{\mathrm{res}}=4-1=3\). The statistic per residual degree of freedom is \(0.1844618/3=0.0614873\), or 0.0615 to four decimal places. The total of the observed counts is 72, matching the total fitted count \(7.2+14.4+21.6+28.8=72\), as expected for this common-probability fit. This very small statistic is a diagnostic quantity; it is not proof that the model is correct.
Common mistake avoided: The third numerator is \((21-21.6)^2=0.36\), not a smaller value. Dividing gives \(0.0260417\); using an incorrect contribution there changes both the total and the ratio.
Worked Example: Poisson Log-Linear Fit
A hypothetical rating analysis records claim counts in four ordered risk bands, indexed by \(x=0,1,2,3\). The counts are \(3,3,7,17\). A Poisson GLM with log link reports fitted means \(2,4,8,16\), corresponding to \(\log(\mu_i)=\beta_0+\beta_1x_i\). Assume independent Poisson responses, so \(Y_i\sim\operatorname{Poisson}(\mu_i)\) and \(V(\mu_i)=\mu_i\). Calculate the statistic and degrees of freedom.
The observed-minus-fitted residuals are \(1,-1,-1,1\). The four contributions are: \(1^2/2=0.5\), \((-1)^2/4=0.25\), \((-1)^2/8=0.125\), and \(1^2/16=0.0625\). Therefore \(X_P^2=0.5+0.25+0.125+0.0625=0.9375\).
The model estimates an intercept and a slope, and the design matrix has rank 2. Thus \(\nu_{\mathrm{res}}=4-2=2\), and \(X_P^2/\nu_{\mathrm{res}}=0.9375/2=0.46875\). As a check on the fitted log-linear structure, the residuals sum to \(1-1-1+1=0\), and their covariate-weighted sum is \(0(1)+1(-1)+2(-1)+3(1)=0\), consistent with the Poisson score equations for the intercept and slope. The calculation uses the Poisson variance \(\mu_i\); dividing by a binomial variance or by the raw count would give the wrong diagnostic.
Common mistake avoided: The four rows do not give four residual degrees of freedom because two independent model parameters were estimated. Subtract the design-matrix rank, not just the intercept, to obtain two.
Worked Example: Poisson Rate With Exposure Offsets
A hypothetical portfolio has three independent claim-count observations, with exposures \(e_i=3,5,8\) in a common exposure unit and observed counts \(2,5,9\). A Poisson model uses a common rate \(\lambda\) and offset \(\log(e_i)\), so \(\mu_i=e_i\lambda\). Assume \(Y_i\sim\operatorname{Poisson}(\mu_i)\). Find the Pearson statistic and residual degrees of freedom.
The rate estimate is total claims divided by total exposure: \(\hat\lambda=(2+5+9)/(3+5+8)=16/16=1\) claim per exposure unit. The fitted means are therefore \(3(1)=3,\ 5(1)=5,\ 8(1)=8\).
The Pearson contributions are \((2-3)^2/3=1/3=0.3333333\), \((5-5)^2/5=0\), and \((9-8)^2/8=1/8=0.125\). Hence \(X_P^2=1/3+0+1/8=11/24=0.4583333\), or 0.4583 to four decimal places.
There are three response rows and one estimated rate parameter; the offset does not add an estimated coefficient. Therefore \(\nu_{\mathrm{res}}=3-1=2\), and \(X_P^2/\nu_{\mathrm{res}}=0.4583333/2=0.2291667\), or 0.2292 to four decimal places. The observed and fitted totals both equal 16, which checks the rate estimate. Exposure belongs in the fitted mean and hence the variance; it is not itself an additional response row.
Common mistake avoided: Using exposure as the denominator in each Pearson contribution would ignore the Poisson variance rule. The correct denominator is the fitted count mean \(e_i\hat\lambda\).
Interpreting the Diagnostic
For a correctly specified model with independent responses, an appropriate variance function, and enough information for the approximation to be credible, \(X_P^2\) can be compared with a chi-square distribution having \(\nu_{\mathrm{res}}\) degrees of freedom. A formal upper-tail diagnostic uses \(P(\chi^2_{\nu_{\mathrm{res}}}\geq X_P^2)\). A small tail probability suggests that the observed discrepancies are unusually large under those assumptions. It does not identify which assumption failed or which predictor needs to change.
A quick descriptive comparison is \(X_P^2/\nu_{\mathrm{res}}\). A value around one is broadly consistent with the scale expected under a unit-dispersion model; a substantially larger value can indicate excess variation or mean-model inadequacy. A substantially smaller value can occur by chance, or may point to dependence or variance assumptions that make the responses less variable than specified. This ratio is an estimate-like summary, not a universal pass/fail threshold. Its interpretation depends on the response distribution and model assumptions.
The chi-square approximation can be poor when fitted means are very small, binomial expected successes or failures are sparse, or the number of response rows is small relative to model complexity. It can also be unreliable when observations are dependent, parameters lie on boundaries, or the variance function is wrong. In those settings, report the limitation rather than treating a numerical comparison as decisive. The aggregate statistic should also be read alongside residuals: a moderate total can conceal one important local discrepancy.
Common Exam Traps
- Using the wrong variance. For Poisson data the denominator is \(\hat\mu_i\); for a grouped binomial count it is \(m_i\hat p_i(1-\hat p_i)\), not just \(m_i\).
- Subtracting the wrong number of parameters. Residual degrees of freedom are generally \(n-\operatorname{rank}(X)\). A factor with several levels may contribute multiple independent columns, while aliased columns do not increase rank.
- Counting trials or exposure as response rows. The number of rows used in the statistic determines \(n\); trial counts and exposure instead affect fitted variances or means.
- Squaring leverage-adjusted residuals for this statistic. The Pearson goodness-of-fit statistic is the sum of squared unadjusted Pearson residuals as defined above. Leverage-adjusted residuals serve a different diagnostic purpose and their squared sum is not generally \(X_P^2\).
- Calling the ratio a chi-square statistic. Compare \(X_P^2\) with a chi-square distribution using its degrees of freedom; the ratio \(X_P^2/\nu_{\mathrm{res}}\) is a separate scale summary.
Check Your Understanding
For each problem, calculate the requested statistic or degrees of freedom from the supplied model information.
- A Poisson GLM has three response rows with observed counts \(5,7,18\) and fitted means \(4,9,16\). Its model-matrix rank is 2. Calculate \(X_P^2\) and the residual degrees of freedom. (Answer: \(X_P^2=1/4+4/9+4/16=0.9444\); \(\nu_{\mathrm{res}}=1\).)
- Three independent binomial groups have trial counts \(20,30,50\) and observed successes \(6,10,22\). The probability \(p=0.40\) is fixed externally, not estimated from these rows. Calculate the unscaled Pearson statistic and its residual degrees of freedom. (Answer: \(X_P^2=4/4.8+4/7.2+4/12=1.7222\); \(\nu_{\mathrm{res}}=3\).)
- A Poisson rate model with an offset has exposures \(3,5,8\), observed counts \(2,5,9\), and fitted means \(3,5,8\). One rate parameter is estimated. Calculate the statistic and residual degrees of freedom. (Answer: \(X_P^2=1/3+0+1/8=0.4583\); \(\nu_{\mathrm{res}}=2\).)
- A fitted GLM uses six response rows. Its model matrix contains seven named columns, but three columns are linearly dependent on the others, leaving rank 4. If \(X_P^2=3.10\), find the residual degrees of freedom and the statistic per residual degree of freedom. (Answer: \(\nu_{\mathrm{res}}=6-4=2\); \(X_P^2/\nu_{\mathrm{res}}=1.55\).)
- A candidate squares Pearson residuals that have each been divided by \(\sqrt{1-h_{ii}}\), where \(h_{ii}\) is the GLM leverage, and calls the sum \(X_P^2\). Is this generally the defined Pearson goodness-of-fit statistic? (Answer: No. It is the sum of squared leverage-adjusted residuals; \(X_P^2\) uses the unadjusted Pearson residuals.)