Why Check a Fitted Genetic Model?
A likelihood model can produce parameter estimates and standard errors even when its assumptions do not describe the observed data well. A goodness-of-fit check asks a different question: after fitting the model, are the observed outcomes reasonably consistent with its predicted distribution? In genetic analyses, the outcomes might be genotype categories, phenotypes within genotype groups, or transmitted alleles in families.
The basic comparison is between observed counts and expected counts. A large discrepancy can flag lack of fit, but it does not identify the cause. Population structure, dependence between observations, genotyping error, selection, or an incorrectly specified genetic model may all contribute. A small discrepancy is not proof that every modeling assumption holds.
Two Goodness-of-Fit Statistics
For multinomial category counts, two common summaries are the Pearson statistic and the likelihood deviance against the saturated model. The saturated model assigns a separate probability to each category and therefore reproduces the observed proportions exactly. The fitted model is compared with that benchmark.
In the deviance, a term with \(O_j=0\) is defined to be zero. Both statistics are nonnegative and grow as observed counts depart from fitted expectations. The Pearson statistic scales each discrepancy by its expected count. The deviance is the likelihood-based comparison with the saturated model.
When the model is regular, the fitted probabilities are not on a boundary, and expected counts are sufficiently large, either statistic is approximately distributed as a chi-square random variable. For a multinomial model with \(K\) categories and \(q\) independently estimable parameters, the reference degrees of freedom are \(K-1-q\). If the model has additional constraints or parameters are estimated in a different way, the degrees of freedom must reflect the actual dimension of the fitted model; the simple formula should not be applied mechanically.
Why Estimation Changes the Degrees of Freedom
The degrees-of-freedom adjustment reflects how many independent ways the data could vary after fitting the model. The \(K\) observed counts sum to \(n\), so only \(K-1\) of them can vary freely. A fitted parameter typically uses one of those independent directions: the model has already adjusted to the data along that direction. Thus the discrepancy left for a goodness-of-fit check has \(K-1-q\) degrees of freedom.
The local relationship between the two statistics also explains why both are used. Write \(O_j=E_j+\delta_j\), where \(\delta_j\) is the count discrepancy. When discrepancies are small relative to expected counts, a Taylor expansion gives:
Across categories, \(\sum_j \delta_j=\sum_j O_j-\sum_j E_j=0\). The first-order terms therefore cancel, leaving \(D\) approximately equal to \(\sum_j\delta_j^2/E_j=X^2\). This approximation, together with regular likelihood theory, motivates the chi-square reference distribution. It is an approximation, not a guarantee for sparse or highly constrained data.
Worked Example: Hardy–Weinberg Genotype Counts
Consider hypothetical genotype counts from 200 independently sampled individuals: 82 \(AA\), 96 \(Aa\), and 22 \(aa\). Check fit to Hardy–Weinberg proportions, estimating the \(A\)-allele frequency from these data.
The fitted allele frequency is \(\hat p=(2(82)+96)/(2(200))=260/400=0.65\). Under Hardy–Weinberg equilibrium, the fitted genotype probabilities are \(\hat p^2=0.4225\), \(2\hat p(1-\hat p)=0.4550\), and \((1-\hat p)^2=0.1225\). The expected counts are therefore 84.5 \(AA\), 91 \(Aa\), and 24.5 \(aa\).
The Pearson statistic is:
There are \(K=3\) categories and one estimated parameter, \(\hat p\), so \(df=3-1-1=1\). The chi-square reference p-value is about 0.44. This is not evidence of a substantial discrepancy from the fitted proportions. The expected counts all exceed 5, supporting the usual large-sample approximation. The calculation assumes independent sampling and that Hardy–Weinberg proportions are an appropriate model for the sampled population; the result does not establish those assumptions.
Residuals Show Where the Discrepancy Occurs
A single goodness-of-fit statistic summarizes the overall discrepancy but can conceal its location. Category residuals help identify which outcomes contribute most. The Pearson residual for category \(j\) is \((O_j-E_j)/\sqrt{E_j}\). Positive values mean more observations than expected; negative values mean fewer. Deviance residuals give a signed version of the category’s contribution to the deviance:
For multinomial counts, the terms \(-(O_j-E_j)\) sum to zero, so the squared deviance residuals sum to \(D\). Residuals are useful for locating patterns, but they are not independent: the counts have a fixed total, and parameter fitting imposes further relationships. Their magnitudes should therefore be read as diagnostics, not as a collection of separate, unadjusted tests.
Worked Example: A Shared Phenotype Probability Across Genotypes
Suppose a hypothetical study observes 100 individuals in each of three genotype groups. The numbers with a phenotype are 20, 30, and 50, respectively. Check a model in which the phenotype probability is the same in all three groups. Assume individuals are independent and phenotype status is recorded without error.
Under the model, the maximum-likelihood estimate of the shared probability is the pooled proportion, \(\hat p=100/300=1/3\). Each group has expected counts of \(100(1/3)=33.33\) with the phenotype and \(100(2/3)=66.67\) without it. All expected counts exceed 5.
The Pearson statistic, summing contributions from both phenotype outcomes in all groups, is:
There are three independent binomial groups. The model with a separate probability for each group has three parameters, while the shared-probability model has one, giving \(df=3-1=2\). Equivalently, this is the two degrees of freedom remaining among three group-specific proportions after fitting their common value. The p-value is about \(2.75\times 10^{-5}\), which is strong evidence against a common phenotype probability in these data. The Pearson residuals for phenotype-positive counts are approximately \(-2.31\), \(-0.577\), and \(2.89\), pointing to fewer positive outcomes in the first group and more in the third than the model predicts. This check detects lack of fit to the shared-probability model; it does not establish a causal effect of genotype.
Sparse Categories and Calibration
The chi-square approximation can be poor when expected counts are small. There is no universal cutoff that makes it valid or invalid: the concern is that a discrete, sparse sampling distribution may differ noticeably from the smooth chi-square reference. A rare genotype or an unlikely transmission category can cause this problem even when the total sample size seems large.
Possible responses include using an exact reference distribution when it is available, or simulating data under the fitted model and recalculating the statistic. In a parametric bootstrap, each simulated data set should be generated under the fitted model and the model parameters should be refitted before computing its goodness-of-fit statistic. Refitting matters because the observed statistic also benefits from fitting parameters to the observed data. Categories should not be combined merely to increase expected counts unless the combined categories are scientifically meaningful and the grouping is justified by the question.
Worked Example: Checking a Mendelian Transmission Model
In a hypothetical set of 50 independent families, each with one informative offspring and parental genotypes that imply two possible transmitted alleles with probabilities \(1/2\) and \(1/2\), suppose the observed counts are 34 and 16. Assume parental genotypes are correct, transmissions are independent across families, and the Mendelian probabilities apply.
The probabilities are specified by the model rather than estimated from these counts, so expected counts are \(50(1/2)=25\) in each category. Both are large enough for the usual approximation. The Pearson statistic is:
With two categories and no fitted parameters, \(df=2-1=1\). The p-value is about 0.011. Under the stated assumptions, these counts are relatively unusual if the two transmission outcomes are equally likely. The test does not determine whether the discrepancy reflects chance, transmission distortion, selection, or a violation of another assumption. If families contributed multiple dependent offspring, the independence assumption would fail and this simple calculation would not be appropriate.
Goodness of Fit for Likelihood Models More Broadly
The count formulas apply directly when outcomes can be grouped into categories with model-predicted probabilities. For individual-level likelihoods, the diagnostic must match the outcome model. For example, binary phenotypes can be assessed through observed and fitted counts in suitable groups, while quantitative outcomes require diagnostics based on their fitted distributions and residuals. Arbitrarily binning continuous outcomes can discard information and make conclusions depend on the chosen bins.
Calibration is the agreement between predicted and observed outcomes. A goodness-of-fit test is one way to examine calibration, but its result depends on sample size: large samples can detect small discrepancies, while small samples may not reveal important ones. Report the observed and expected counts, the statistic, degrees of freedom, and the p-value, and inspect residuals for meaningful patterns. A non-small p-value means the test did not detect a discrepancy of the measured kind; it does not prove that the model is correct.
Common Mistakes
- Using \(K-1\) degrees of freedom after estimating parameters. Fitting parameters uses information from the data. For a regular multinomial model, subtract the number of independently estimated parameters from \(K-1\).
- Interpreting a non-small p-value as proof of fit. The test may have limited power, and it only checks the discrepancies captured by its statistic and sampling assumptions.
- Treating sparse expected counts as harmless. A chi-square approximation may be unreliable in sparse data. Consider exact or simulation-based calibration, with refitting when parameters were estimated.
- Reading a significant result as an explanation. A small p-value flags inconsistency with the model, but does not identify its source or establish a causal mechanism.
Check Your Understanding
Try these questions before reviewing the explanations above.
- A multinomial model has four categories and estimates two independent parameters. Under the regularity conditions for the usual approximation, what are the goodness-of-fit degrees of freedom?
- What does a positive Pearson residual for a genotype category indicate?
- Why can a chi-square reference p-value be unreliable when some fitted expected counts are very small?
- In a parametric bootstrap goodness-of-fit check, why should parameters be refitted in each simulated data set?
- A goodness-of-fit test gives a small p-value for a transmission model. Name one conclusion it supports and one conclusion it does not support.