Why Hold Out Data When Comparing Mechanisms?
A mechanistic model can describe the data used to calibrate it without predicting new observations well. This is especially relevant when competing QSP models encode different biological hypotheses but have different parameter flexibility or respond differently to sparse measurements. Predictive cross-validation compares the mechanisms by repeatedly fitting them without some observations and scoring how well they predict those held-out data.
The comparison is only meaningful when the held-out units represent the prediction task of interest. Predicting a later time point for a participant whose earlier measurements are available is not the same task as predicting a new participant with no individual measurements. The fold design must reflect that distinction.
For mechanisms \(M_1\) and \(M_2\), a comparison requires a common outcome definition, data partition, loss function, and calibration protocol. The biological structures can differ; the information available for fitting and the rules used to score predictions should not. The information-criteria material introduced earlier compares fit and complexity through a specified criterion. Cross-validation instead evaluates predictions on data excluded from each fit; neither approach makes a mechanism biologically true merely because it scores better.
Scoring Held-Out Predictions
Let \(y_i\) be a held-out observation and \(\hat{y}_{i,-k}\) the prediction for it from a model fitted without fold \(k\). For a continuous outcome with meaningful squared deviations, the squared-error loss is \((y_i-\hat{y}_{i,-k})^2\). A common cross-validation mean squared error is the average of these losses over all held-out observations. Its square root is the root mean squared error (RMSE), in the original outcome units.
Here \(F_k\) is the set of observations in fold \(k\), and \(N\) is the total number scored. MSE has squared outcome units; RMSE has outcome units. Other losses may be appropriate for other observation types or scientific targets, but the choice must be made consistently across mechanisms and interpreted according to the loss. This tutorial uses squared error for its numerical examples.
Worked Example: Comparing Two Mechanisms on Held-Out Concentrations
Worked Example: Comparing Two Mechanisms on Held-Out Concentrations
Suppose four held-out concentration observations from a hypothetical experiment are \(10,12,9,\) and \(11\) mg/L. The predictions shown below were generated by fitting each mechanism without the corresponding scored observations. Use squared error to compare the predictions.
| Observation | Observed (mg/L) | Mechanism A prediction (mg/L) | Mechanism B prediction (mg/L) |
|---|---|---|---|
| 1 | 10 | 11 | 9 |
| 2 | 12 | 10 | 11 |
| 3 | 9 | 10 | 10 |
| 4 | 11 | 8 | 10 |
For mechanism A, define the prediction error as observed minus predicted. The errors are \(10-11=-1\), \(12-10=2\), \(9-10=-1\), and \(11-8=3\) mg/L. Therefore,
For mechanism B, the errors are \(10-9=1\), \(12-11=1\), \(9-10=-1\), and \(11-10=1\) mg/L. Its score is
On these held-out observations, mechanism B has the lower squared-error score. The result supports better predictive performance for this particular held-out design, not a conclusion that mechanism B is biologically correct. With only four observations, the comparison may also be sensitive to which observations were held out; repeated, appropriately grouped folds can reveal that instability.
Choose Folds to Match the Prediction Task
In longitudinal QSP data, measurements from the same subject are usually related through that subject’s evolving biological state and shared characteristics. Randomly assigning individual time points to folds can place early and late observations from one subject in both training and test sets. That design may evaluate interpolation within a partially observed trajectory, while appearing to evaluate prediction for a new subject. It can also leak subject-specific information into the fit.
If the intended task is prediction of future measurements for subjects whose earlier data are available, use a time-ordered split: train on measurements available through a specified time and score later measurements. If the task is prediction for a new subject, keep all observations from each subject together and hold out entire subjects. If the intended task is prediction for new subjects at future times, a design must withhold subjects and respect time ordering; the test data should not influence fitting or any preprocessing.
Worked Example: Testing Future-Time Prediction
Consider a hypothetical longitudinal concentration profile for one study setting. The observed concentrations at times \(1,2,3,4,5\) are \(2,4,6,8,10\) mg/L. The prediction target is future measurements after the first three times, so fit each mechanism using only times 1 through 3, then score times 4 and 5. Suppose the resulting predictions are 7 and 9 mg/L for mechanism A, and 7.5 and 8 mg/L for mechanism B.
For mechanism A, the held-out errors are \(8-7=1\) and \(10-9=1\) mg/L. Its held-out MSE is
For mechanism B, the errors are \(8-7.5=0.5\) and \(10-8=2\) mg/L, so
For this future-time split, mechanism A predicts better by squared error. This small example illustrates the time-block logic, not a reliable general ranking: a single trajectory and two scored values provide little basis for generalizing to other subjects or study conditions.
Multi-Subject Folds and the Meaning of the Average
When the prediction target is a new subject, a natural design is leave-one-subject-out cross-validation: fit on all but one subject, predict the omitted subject, and repeat until every subject has been held out. For larger studies, subjects can instead be divided into \(K\) groups, with all measurements from a subject assigned to one group. A subject must not appear on both sides of a fold if the goal is genuinely new-subject prediction.
The way held-out errors are aggregated also defines the target. Averaging all squared errors gives more weight to subjects contributing more observations. Averaging each subject’s mean squared error gives subjects equal weight, regardless of their number of measurements. Neither is universally preferable; use the one matching the intended prediction target and state it.
Worked Example: Observation-Weighted and Subject-Weighted Scores
Suppose three hypothetical subjects are each held out in turn. Subject 1 contributes two observations, subject 2 contributes two, and subject 3 contributes one. The following are the held-out errors, in mg/L, from the leave-one-subject-out fits.
| Subject | Mechanism A errors (mg/L) | Mechanism B errors (mg/L) |
|---|---|---|
| 1 | 1, -1 | 1, 1 |
| 2 | 2, 2 | 1, 1 |
| 3 | 0 | 3 |
For mechanism A, the total squared error is \(1+1+4+4+0=10\), so the observation-weighted MSE over five observations is \(10/5=2.00\;(\mathrm{mg/L})^2\). For mechanism B, the total is \(1+1+1+1+9=13\), giving \(13/5=2.60\;(\mathrm{mg/L})^2\). Thus A has the lower observation-weighted score.
For an equal-subject comparison, first calculate each subject’s mean squared error. For A, these are \(1.00\), \(4.00\), and \(0\;(\mathrm{mg/L})^2\), respectively, giving an equal-subject mean of \((1+4+0)/3=1.667\;(\mathrm{mg/L})^2\). For B, they are \(1.00\), \(1.00\), and \(9.00\;(\mathrm{mg/L})^2\), giving \((1+1+9)/3=3.667\;(\mathrm{mg/L})^2\). A also ranks better with equal subject weighting.
The numerical ranking happens to agree, but the scores differ because the aggregation targets differ. These calculations presuppose that the held-out predictions were obtained without using any data from the subject being scored.
Why Cross-Validation Estimates Predictive Error
A short justification explains both the value and the limitation of the procedure. Suppose \(Z_1,\ldots,Z_n\) are exchangeable independent prediction units, and let \(L(Z_i,\hat f_{-i})\) be the loss for unit \(i\) under a predictor fitted without that unit. Leave-one-unit-out cross-validation averages these losses. By exchangeability, each omitted unit has the same expected loss as a fresh unit evaluated after fitting on \(n-1\) units. Linearity of expectation then gives
This equality depends on the stated exchangeability and on holding out the true prediction unit. For multi-subject prediction, \(Z_i\) should represent a subject, not an individual measurement from a subject. The result concerns a predictor trained on \(n-1\) units, not exactly the final model trained on all \(n\). With \(K\)-fold cross-validation, each fit uses fewer than all observations, so its estimated performance likewise corresponds approximately to that training size. Dataset shifts, dependent units, poor fold construction, and highly variable scores can undermine the intended interpretation.
Diagnostics, Alternatives, and Common Pitfalls
Before interpreting a ranking, check that each fold’s training data contain enough information to fit each mechanism, that the optimization procedure converged, and that all models were scored on the same held-out outcomes. Record fold-level scores as well as the aggregate. If one fold dominates the total, or if rankings change sharply across folds, the evidence for a stable preference is weak. When the available subjects are few, the variability of cross-validation scores can itself be substantial.
Any data-dependent operation must be performed within each training fold. This includes estimating scaling constants, selecting covariates, choosing a model variant, or tuning a fitting setting. If those choices use held-out outcomes, the reported score no longer represents prediction on untouched data. When the same cross-validation results are used to choose among many mechanisms or tuning choices, the minimum score may be optimistically low. A nested design can address this: use inner folds for choices and outer held-out folds for evaluation. An untouched external test set is another option when enough suitable data are available.
- Common mistake: random point-wise folds automatically represent new-subject prediction. They do not if the same subjects contribute to training and test sets. Group all observations from each subject when the target is a new subject.
- Common mistake: the lowest score proves the mechanism is true. It establishes only a relative predictive result under the specified data, loss, folds, and fitting procedure.
- Common mistake: more observations per subject should always mean more influence. That follows only for an observation-weighted target. An equal-subject target requires averaging subject-level losses.
- Common mistake: fit each model once, then score the same fit on held-out data. Each fold requires a fresh fit using only its training data; otherwise the held-out outcomes may already have influenced the predictions.
Information criteria offer a computationally convenient alternative when their assumptions and likelihood formulation are appropriate, while cross-validation directly assesses a chosen held-out prediction task. Cross-validation can be computationally demanding, especially when QSP calibration is costly, and its result depends on the fold design and score. It does not repair misspecified observation assumptions or ensure that the held-out data represent future applications. A lower cross-validation loss is evidence about prediction under a defined target, not a substitute for biological interpretation or experimental judgment.
Check Your Understanding
Answer each question, then compare your reasoning with the solutions.
- A study aims to predict a new participant’s complete concentration profile. Should individual time points or whole participants be held out? Why?
- For held-out observations of 5 and 7 mg/L, a mechanism predicts 6 and 6 mg/L. Calculate its MSE and RMSE.
- When does a pooled observation-level MSE give more weight to one subject than another?
- Why can random time-point folds be misleading when the intended task is prediction of future measurements?
- What does the derivation of leave-one-unit-out cross-validation assume about the prediction units?
Solutions. (1) Hold out whole participants, so no measurements from a scored participant contribute to fitting; this matches new-participant prediction. (2) The errors are \(5-6=-1\) and \(7-6=1\) mg/L. Thus MSE \(=[(-1)^2+1^2]/2=1.00\;(\mathrm{mg/L})^2\), and RMSE \(=\sqrt{1}=1.00\) mg/L. (3) When subjects contribute different numbers of observations, pooled MSE gives greater weight to subjects with more scored observations. (4) Training can include other measurements from the same subject, allowing subject-specific information from later times to inform the fit and turning a future-prediction task into a different task. (5) The units should be exchangeable independent cases for the prediction target, and each held-out case must be excluded from fitting; for new-subject prediction, the unit is the subject rather than an individual repeated measurement.