Why Calibrate a Dispersion Check by Simulation?
A Pearson or deviance statistic can indicate that a fitted binomial or Poisson model leaves more variation unexplained than its mean–variance specification allows. In many settings, a reference distribution based on a large-sample approximation is used to judge whether the statistic is unusually large. That approximation can be doubtful when the sample is small, the data are sparse, or the fitted model has features that make the approximation unreliable.
Parametric simulation offers a direct alternative calibration. It asks: if the fitted model generated new responses under the same design, how often would the same diagnostic statistic be at least as large as the one observed? The procedure is useful only if the simulation reproduces the model being assessed and the fitting and diagnostic steps are repeated consistently.
Definition and Simulation Procedure
Suppose the observed responses are \(Y_1,\ldots,Y_n\), with fixed covariates or design, and a binomial or Poisson GLM is fitted. Write \(\hat{\mu}_i\) for the fitted mean of a Poisson response and \(\hat{p}_i\) for the fitted success probability of a binomial response with \(m_i\) trials. The usual Pearson statistics are
The corresponding residual deviances are
In these formulas, a term of the form \(0\log(0/a)\), for \(a>0\), is defined to be zero by continuity. Larger values are evidence of a discrepancy between the observations and the fitted model, but they do not by themselves identify the reason for it.
For each of \(B\) simulations, generate responses from the fitted model conditional on the observed design, refit the same model using the same fitting rules, and calculate the same statistic. Denote the resulting values by \(T_1^*,\ldots,T_B^*\), and the observed value by \(T_{\mathrm{obs}}\). A common Monte Carlo upper-tail estimate is
The added one prevents a zero estimate when no simulated value reaches the observed statistic. It does not make a fitted-model simulation an exact test for a composite model: the fitted parameter values are estimates, not known null parameters.
Worked Examples
Worked Example: A Poisson Intercept-Only Fit
Consider three independent Poisson counts \(Y=(0,1,2)\) under an intercept-only model, so every observation has mean \(\mu\). The maximum-likelihood estimate is the sample mean:
The observed Pearson statistic is
For the deviance, the zero count contributes \(1\), since its logarithmic term is zero. The count of 1 contributes \(1\log(1/1)-(1-1)=0\), and the count of 2 contributes \(2\log(2/1)-(2-1)=2\log 2-1\). Thus
To generate a replicate, draw three independent Poisson variables with mean 1, then fit the intercept-only model again by taking their sample mean. For example, if a simulated response is \((0,0,3)\), its refitted mean is also 1. Its Pearson statistic is \(1+1+4=6\), and its deviance is
This replicate illustrates why the model must be refitted: the diagnostic is calculated from the fitted replicate, not from a fixed reference mean copied into every calculation. The observed statistic alone does not determine a calibrated tail probability; that requires the full set of simulated replicates.
Worked Example: A Binomial Intercept-Only Fit
Suppose four independent groups each have \(m_i=5\) trials, with observed success counts \(Y=(1,2,4,5)\). Under a common-probability model, the fitted probability is
Each fitted success count is \(5(0.6)=3\), and the Pearson denominator in each group is \(5(0.6)(0.4)=1.2\). Therefore
The four contributions inside half the deviance are, in order,
The sum is approximately \(5.091151\), giving \(D_{\mathrm{B,obs}}\approx 10.1823\). For each simulation, generate four independent \(\operatorname{Bin}(5,0.6)\) counts and refit the common probability from their total. For instance, a replicate \((0,3,3,5)\) has total 11 and refitted probability \(11/20=0.55\). Its fitted count per group is 2.75, and its Pearson statistic is
This single replicate exceeds the observed Pearson statistic, but it is not itself a tail probability. The proportion of all simulated statistics at least as large as 8.3333 supplies the calibration estimate.
Worked Example: Interpreting a Monte Carlo Tail Estimate
Suppose a correctly specified simulation run uses \(B=999\) replicates, and 23 replicate statistics are at least as large as the observed statistic. The plus-one estimate is
This says that the simulated upper tail is about 2.4% under the fitted-model simulation procedure. It is not a probability that the model is true, and, because the parameters were estimated, it is not generally an exact null p-value.
There is also Monte Carlo error: a finite simulation estimates a tail probability with noise. Treating the 999 exceedance indicators as Bernoulli outcomes gives the approximate standard error
The estimate is therefore imprecise at this simulation size; a small change in the simulated exceedance count can noticeably change the reported tail estimate. If a decision depends on distinguishing a small tail probability from a nearby threshold, increase \(B\) and report enough information to show the simulation size and exceedance count.
Why Refit Every Replicate?
The statistic being calibrated is calculated after estimating model parameters from data. If simulated responses are generated from the fitted model but the original estimates are reused for every replicate, the simulated statistics omit the variability introduced by fitting. Refitting mimics the complete analysis applied to the observed data: generate responses, estimate parameters, then calculate the diagnostic.
Keep the observed covariates, trial counts, or exposures fixed, and record the observed Pearson or deviance statistic.
For a Poisson GLM, draw independent counts with the fitted means. For a binomial GLM, draw counts with the specified trial counts and fitted probabilities.
Apply the same model specification and fitting rules to the replicate, then calculate the same statistic from its refitted values.
Count replicate statistics greater than or equal to the observed statistic and report the Monte Carlo estimate with its simulation size.
If a replicate fit fails or reaches a boundary where the statistic is undefined, that event must not be silently discarded. The fitting procedure and a rule for handling such replicates should be stated; frequent failures can indicate that this calibration is not reliable for the problem at hand.
What the Calibration Does—and Does Not—Establish
A simple-null Monte Carlo rank calculation has a precise validity property. Suppose the null distribution is fully specified, the observed statistic and \(B\) simulated statistics are independent draws from that same distribution, and ties are handled by counting simulated values greater than or equal to the observed value. Then the plus-one upper-tail value is conservative: its probability of being at most \(\alpha\) is no greater than \(\alpha\). To see this, let \(N=B+1\) and randomly break any ties among the \(N\) exchangeable statistics. The rank of the observed statistic in this ordering is uniform on \(1,\ldots,N\). The count using “greater than or equal to” is at least that tie-broken rank, so the plus-one tail value is at least the tie-broken rank divided by \(N\). Consequently, the event that the tail value is at most \(\alpha\) is contained in the event that the uniform rank divided by \(N\) is at most \(\alpha\), whose probability is \(\lfloor \alpha N\rfloor/N\leq\alpha\). Thus the test is conservative, including when ties occur. \(\square\)
In a fitted GLM, however, the observed data and the simulated data are not generally exchangeable under a composite null: the simulation uses estimated parameters. The rank argument therefore does not establish exact finite-sample validity for the plug-in calibration. Its purpose is to approximate the diagnostic’s null behavior under the fitted model, especially when a standard asymptotic reference is doubtful.
The Monte Carlo error calculation also has a direct justification. If the model and fitted parameters are held fixed and each replicate is generated independently, define \(I_b=I(T_b^*\geq T_{\mathrm{obs}})\). Each \(I_b\) is Bernoulli with success probability \(q=P(T^*\geq T_{\mathrm{obs}})\), so \(E[I_b]=q\), \(\operatorname{Var}(I_b)=q(1-q)\), and independence gives
This describes simulation error conditional on the fitted model; it does not account for uncertainty in the fitted parameters or for whether the model itself is adequate.
Common Pitfall and Practical Interpretation
Wrong reasoning: “The observed statistic is large, so the fitted model must have overdispersion.” A large statistic relative to a simple reference can instead reflect the behavior of the fitted statistic in a small or sparse sample, or a departure from the assumed mean structure. Simulation calibrates how unusual the statistic is under the chosen fitted model; it does not diagnose the cause of a discrepancy.
Correction: State the model used to generate replicates, keep the design fixed, refit every replicate, and interpret the upper-tail estimate as a model-conditional diagnostic. A small simulated tail indicates that the observed statistic is unusual under that procedure. It is a reason to investigate the model and data, not a standalone proof of extra variation.
Check Your Understanding
Use these questions to check both the mechanics and the interpretation of simulation calibration.
- Why should the model be refitted for every simulated response before calculating its Pearson statistic?
- In a Poisson GLM simulation, which parts of the observed data are held fixed, and which are generated anew?
- If 8 of 499 replicate deviances are at least as large as the observed deviance, calculate the plus-one Monte Carlo estimate.
- Why does the exact rank argument for a fully specified simple null not automatically prove exact validity for a plug-in fitted-model calibration?
- What does a small simulated upper-tail estimate indicate, and what does it not establish about the source of the discrepancy?