From Frozen Models to an External Comparison
External validation asks how well predictions from an already specified model perform for records that were not used to fit or revise it. A useful worked analysis must preserve that separation all the way through the calculation: the model, its parameters, the prediction procedure, and any averaging weights are fixed before the evaluation outcomes are examined. Otherwise, apparent validation performance can be optimistic because information from the evaluation set has influenced the predictions being assessed.
Here, the model predictions are hypothetical, and the four records below are hypothetical external concentration-time records. The purpose is to demonstrate the analysis, not to represent a clinical study. Both candidate models provide a predictive distribution for each record. For transparent arithmetic, these distributions are specified as normal on the concentration scale. Model A has a predictive standard deviation of \(0.4\) mg/L, and Model B has a predictive standard deviation of \(0.7\) mg/L. All records are assumed to have been correctly matched to the same external subject, nominal time, dose history, and covariates used to produce each prediction.
| External record | Observed \(y_i\) (mg/L) | Model A mean (mg/L) | Model A SD (mg/L) | Model B mean (mg/L) | Model B SD (mg/L) |
|---|---|---|---|---|---|
| 1 | 0.8 | 0.7 | 0.4 | 0.9 | 0.7 |
| 2 | 1.2 | 1.0 | 0.4 | 1.3 | 0.7 |
| 3 | 0.6 | 0.8 | 0.4 | 0.5 | 0.7 |
| 4 | 1.0 | 0.9 | 0.4 | 0.5 | 0.7 |
The normal distributions are a simplifying assumption for this worked calculation, not a universal choice for concentration data. A normal distribution has support below zero, which can be implausible for concentrations. In particular, Model B's distribution for record 4, \(N(0.5,0.7^2)\), assigns appreciable probability to negative values. A practitioner should use the predictive distribution actually justified by the model and measurement process, and examine whether its shape and support are credible.
Check the Records Before Scoring
Before computing a score, verify that each observed concentration is paired with the prediction for the same record and that units, time definitions, dosing history, and relevant covariates agree. For example, a prediction at 8 hours cannot be compared with an observed concentration at 12 hours merely because both belong to the same subject. The model and its prediction procedure must also remain frozen: no evaluation outcome should be used to refit parameters, revise the model, choose covariates, or tune the prediction method.
Worked Example: Confirming a Valid Record Match
Suppose external record 4 is defined as a concentration measured at 8 hours after a specified dose, with the covariates recorded for that occasion. Its observed value is \(1.0\) mg/L. The table reports Model A's prediction as \(N(0.9,0.4^2)\) and Model B's as \(N(0.5,0.7^2)\).
The comparison is aligned only if both predictions were generated for that same 8-hour occasion, dose history, and covariate record, and if the observed and predicted concentrations use mg/L. Once that is confirmed, \(y_4=1.0\) mg/L can be scored against both distributions. If the observed value were instead a 12-hour measurement, the correct action would be to obtain predictions for 12 hours, not to score the 8-hour predictions against it.
The check also concerns information use. If the value \(1.0\) mg/L was used to update a subject-specific estimate or to tune the model before making the prediction, it is not an untouched external prediction for that record under this validation design. The analysis must describe such conditioning honestly rather than treating the prediction as fully external.
Calibration and Error Summaries
A simple calibration summary is the mean prediction error, here defined as observed minus predicted concentration. A positive value indicates underprediction on average for the records being summarized; a negative value indicates overprediction. It is not a complete calibration assessment, because positive and negative errors can cancel. Root mean squared error (RMSE) summarizes the typical magnitude of errors while giving larger errors extra weight.
Worked Example: Mean Error and RMSE for Model A
Model A's predicted means are \(0.7, 1.0, 0.8,\) and \(0.9\) mg/L; the observed concentrations are \(0.8, 1.2, 0.6,\) and \(1.0\) mg/L. The errors, calculated as observation minus prediction, are \(0.1, 0.2, -0.2,\) and \(0.1\) mg/L.
Thus the mean prediction error is $$ \overline{e}_A=\frac{0.1+0.2-0.2+0.1}{4} =\frac{0.2}{4}=0.0500\ \mathrm{mg/L}. $$
The mean squared error is \((0.1^2+0.2^2+(-0.2)^2+0.1^2)/4=(0.01+0.04+0.04+0.01)/4=0.0250\ (\mathrm{mg/L})^2\). Therefore, $$ \mathrm{RMSE}_A=\sqrt{0.0250}=0.1581\ \mathrm{mg/L}. $$
For these four records, Model A underpredicts by \(0.0500\) mg/L on average, and its RMSE is \(0.1581\) mg/L. The small positive average error does not imply that every record is underpredicted: records 1, 2, and 4 are underpredicted, while record 3 is overpredicted.
Predictive interval coverage provides a different check: it records the fraction of observations falling inside intervals from the predictive distributions. For a normal predictive distribution, a central 90% interval is \(\mu_i\pm 1.645\sigma_i\). For Model A this gives a half-width of \(1.645(0.4)=0.658\) mg/L. Its four intervals are centered at \(0.7, 1.0, 0.8,\) and \(0.9\) mg/L, and all four observations fall inside their respective intervals. Model B's half-width is \(1.645(0.7)=1.1515\) mg/L, and its four observations also fall inside. The observed coverage is therefore \(4/4=100\%\) for each model in this tiny example. That result is highly imprecise and does not demonstrate that either model has 90% coverage in the population. Coverage should be interpreted alongside interval width: wider intervals can cover more observations while providing less precise predictions.
Scoring Predictive Distributions
A point prediction score evaluates a chosen summary such as the predictive mean. A distributional score evaluates the predictive distribution itself, including both its location and spread. For a continuous outcome, the logarithmic predictive score can be expressed as the log density assigned to the observed value. Larger log predictive density is better; equivalently, the negative log predictive density is a loss, for which smaller is better. Densities are not probabilities at an exact point, and their numerical values depend on the measurement units, so comparisons require the same outcome and units.
Worked Example: Scoring One Observation Under Both Models
For record 4, \(y_4=1.0\) mg/L. Under Model A, \(\mu_{A4}=0.9\) mg/L and \(\sigma_{A4}=0.4\) mg/L. The predictive density is $$ f_A(1.0)=\frac{1}{0.4\sqrt{2\pi}} \exp\left[-\frac{1}{2}\left(\frac{1.0-0.9}{0.4}\right)^2\right] \approx 0.9667\ (\mathrm{mg/L})^{-1}. $$
Under Model B, \(\mu_{B4}=0.5\) mg/L and \(\sigma_{B4}=0.7\) mg/L. Substitution gives $$ f_B(1.0)=\frac{1}{0.7\sqrt{2\pi}} \exp\left[-\frac{1}{2}\left(\frac{1.0-0.5}{0.7}\right)^2\right] \approx 0.4416\ (\mathrm{mg/L})^{-1}. $$
The corresponding log densities are approximately \(-0.0339\) for Model A and \(-0.8174\) for Model B. Model A assigns greater density to this observation. This comparison does not say that the observation has a probability of 0.9667 under Model A: for a continuous distribution, the probability of observing any single exact value is zero. The density is a score of how concentrated the predictive distribution is around that value.
Applying the density formula to all four observations gives Model A densities of approximately \(0.9667, 0.8802, 0.8802,\) and \(0.9667\) \((\mathrm{mg/L})^{-1}\). Model B's densities are approximately \(0.5641, 0.5641, 0.5641,\) and \(0.4416\) \((\mathrm{mg/L})^{-1}\). Their mean log predictive densities are approximately \(-0.08077\) and \(-0.6337\), respectively. Thus Model A has the better mean log score in this illustrative set, while Model B's larger predictive SD does not compensate for its lower density at these observations. This is a comparison on four records, not a general ranking of the models.
Scoring a Stacked Predictive Mixture
A predictive mixture combines distributions, not parameter vectors. Let \(w_A\) and \(w_B\) be nonnegative weights that sum to one and are fixed before the evaluation outcomes are scored. At record \(i\), the mixture density is \(w_A f_{Ai}(y_i)+w_B f_{Bi}(y_i)\). The mixture mean is the same weighted average of the component means, but the mixture distribution generally is not a normal distribution with that mean and an averaged parameter vector. We use weights \(w_A=0.6\) and \(w_B=0.4\), stipulated here as having been estimated on a separate stacking dataset and then frozen.
This distinction follows directly from the definition of a mixture. The predictive density is obtained by summing the component densities with their weights, and the log score is then applied to that density. In general, \(\log(w_A f_A+w_B f_B)\ne w_A\log(f_A)+w_B\log(f_B)\). Because the logarithm is concave, Jensen's inequality gives \(\log(w_A f_A+w_B f_B)\ge w_A\log(f_A)+w_B\log(f_B)\) for positive densities and weights that sum to one. But this inequality compares mixture log density with the weighted component log densities for that record; it does not guarantee that the mixture beats the best single model on a validation set.
Worked Example: Mixture Density and Mixture RMSE
At record 4, the component densities are \(f_{A4}(1.0)\approx0.9667\) and \(f_{B4}(1.0)\approx0.4416\) \((\mathrm{mg/L})^{-1}\). The mixture density is $$ f_{\mathrm{mix},4}(1.0) =0.6(0.9667)+0.4(0.4416) \approx0.7566\ (\mathrm{mg/L})^{-1}. $$ Its log predictive density is approximately \(\log(0.7566)=-0.2789\).
The mixture's mean predictions are \(0.6(0.7)+0.4(0.9)=0.78\), \(0.6(1.0)+0.4(1.3)=1.12\), \(0.6(0.8)+0.4(0.5)=0.68\), and \(0.6(0.9)+0.4(0.5)=0.74\) mg/L. Their errors are \(0.02, 0.08, -0.08,\) and \(0.26\) mg/L. Thus $$ \mathrm{RMSE}_{\mathrm{mix}} =\sqrt{\frac{0.02^2+0.08^2+(-0.08)^2+0.26^2}{4}} =\sqrt{0.0202} \approx0.1421\ \mathrm{mg/L}. $$
The mixture mean's RMSE is smaller than Model A's \(0.1581\) mg/L in these data, but the mixture's mean log predictive density, approximately \(-0.2651\), is worse than Model A's \(-0.08077\). A favorable point-prediction summary therefore does not ensure a favorable distributional score. The four mixture densities are approximately \(0.8057, 0.7537, 0.7537,\) and \(0.7566\) \((\mathrm{mg/L})^{-1}\); averaging their log values gives about \(-0.2651\).
Stacking weights are chosen to optimize predictive performance on data reserved for that purpose, not by looking at the outcomes in the final evaluation set and then reporting the same set as untouched validation. Bayesian model averaging (BMA) instead uses model probabilities under a specified Bayesian model comparison framework to weight the predictive distributions. Both approaches average predictive distributions, but the interpretation and method for obtaining the weights differ. Neither approach averages the models' parameter estimates and treats that average as an automatically valid predictive model.
Reading the Comparison and Its Limitations
The numerical summaries do not all answer the same question. In this example, Model A has smaller RMSE than Model B, better mean log predictive density, and the same observed 90% interval coverage. The mixture has the smallest RMSE but does not have the best log predictive score. Reporting several prespecified summaries makes these distinctions visible. A strong analysis also examines error patterns by time, concentration range, site, and covariate support, rather than allowing an overall average to conceal systematic failures.
For a small evaluation set, apparent differences are unstable. Four records cannot establish transportability to a broad patient population, and the observed coverage proportion has considerable sampling uncertainty. Records from the same subject may also be dependent; treating them as independent replicates for uncertainty calculations can overstate the effective amount of information. This worked example therefore describes calculated performance, not a formal inferential claim about a population-level difference.
A further diagnostic is to inspect the predictive distributions themselves. The normal approximation used here assigns probability to negative concentrations, especially for Model B where the mean is \(0.5\) mg/L and the SD is \(0.7\) mg/L. If this conflicts with the scientific measurement process, density scores from that approximation may penalize or reward the model in misleading ways. A suitable positive-valued or otherwise scientifically justified predictive distribution should be used in a real analysis. Scores should also be calculated on a consistent outcome scale; density values change under unit transformations, even though correctly adjusted relative comparisons on the same data remain coherent.
Common Mistakes
- Updating the model with evaluation outcomes. Calling predictions external after using the same outcomes to refit or tune them breaks the intended separation. Freeze models and prediction procedures before evaluation.
- Scoring mismatched records. A wrong time, dose history, covariate record, or unit can produce an apparent model failure that is actually a data-alignment failure. Confirm the match before calculating metrics.
- Averaging log scores instead of densities. The mixture log score is \(\log(\sum_m w_m f_{mi}(y_i))\), not \(\sum_m w_m\log f_{mi}(y_i)\). Form the mixture density first.
- Equating good mean predictions with good distributions. RMSE uses predictive means; log score also responds to predictive spread and shape. Report which aspect each metric assesses.
- Overinterpreting a small external sample. Excellent observed coverage or a modest difference in average scores on a few records is not conclusive evidence of population-level performance.
Check Your Understanding
Answer each question using the definitions and calculations above.
- For Model A, what does a mean prediction error of \(0.0500\) mg/L mean in context?
- Why is the mixture log score not the weighted average of the component log scores?
- For record 4, calculate the mixture density using the stated weights and component densities.
- Why does \(4/4\) observed coverage of the 90% intervals not establish 90% population coverage?
- Name one reason that the normal predictive distribution for Model B could be inappropriate for concentrations.
Solutions. (1) The observations exceed Model A's predictions by \(0.0500\) mg/L on average across these four records; individual errors can have either sign. (2) The predictive mixture density is formed by weighting and adding the component densities, and its log is then taken: \(\log(0.6f_A+0.4f_B)\), which generally differs from \(0.6\log(f_A)+0.4\log(f_B)\). (3) \(0.6(0.9667)+0.4(0.4416)=0.75666\), approximately \(0.7566\ (\mathrm{mg/L})^{-1}\). (4) Four records provide a very imprecise empirical coverage estimate; the result does not establish long-run coverage in a target population. (5) A normal distribution can assign probability to negative concentrations, and Model B's SD is large relative to its mean.