3.5 Covariates and evaluation: cov, forest, vpc
The base model describes a typical subject and the scatter around it. It does not yet say why clearance and volume differ
between people. This section asks that question in four commands: cov tests candidate covariate effects, fit refits
the model with the retained ones, forest draws the effects, and vpc checks the model against the data before and after.
3.5.1 cov: which covariates matter?
The classical way to test a covariate is to refit the model with it and compare the objective function; with six candidates
and a stepwise search, that is dozens of NONMEM runs. The frozen-model engine of cov takes a shortcut that is exact enough
to rank and select: it holds the fitted base model fixed, and for each candidate computes a score test, an approximation of
how much the objective would fall if the effect were added and the model refitted. It then confirms the final choice with
one joint refit.
The settings are in nlmx.covar, which generate wrote. They list the candidates:
[covariates]
CL = ["WT", "SEX", "EGFR", "CRCL"]
V = ["WT", "SEX"]
nlmx cov --config nlmx.covar --method frozen -o out_frozen
It takes about 6 seconds. The console log shows the work in the order a modeller would do it:
0.01s info covariate `WT`: continuous (detected; 198 distinct values, 31.53 to 141.4) — equations: power
0.01s ok 6 candidate relationship(s) constructed
0.02s ok base -2LL = -2880.2130 over 200 subjects (400 subject evaluations so far)
0.20s info CL~WT:power -> S = 67.5331 on 1 df, p = 2.0718e-16, one-step beta = [1.02405]
0.20s info CL~SEX:proportional -> S = 0.2007 on 1 df, p = 6.5417e-1, one-step beta = [-0.02866]
0.20s info CL~EGFR:power -> S = 25.4627 on 1 df, p = 4.5101e-7, one-step beta = [0.51049]
0.20s info CL~CRCL:power -> S = 22.9349 on 1 df, p = 1.6758e-6, one-step beta = [0.47238]
0.21s info V~WT:power -> S = 102.6449 on 1 df, p = 4.0095e-24, one-step beta = [1.02884]
0.21s info V~SEX:proportional -> S = 1.2314 on 1 df, p = 2.6714e-1, one-step beta = [0.05540]
0.21s info multiplicity adjustment `bh` applied to 6 p-value(s)
0.21s ok step 1: selected `V~WT:power` (conditional p = 4.009e-24, S = 102.645, one-step beta = [1.02884])
0.75s ok step 2: selected `CL~WT:power` (conditional p = 4.787e-9, S = 34.274, one-step beta = [0.73827])
1.28s ok step 3: selected `CL~EGFR:power` (conditional p = 6.778e-8, S = 29.127, one-step beta = [0.64532])
1.77s info step 4: best remaining candidate `V~SEX:proportional` has conditional p = 5.450e-2 >= 0.05 — stopping
5.64s ok final model refit: OFV -3139.7047; coefficients [1.03359, 0.58755, 0.93429]
Three stages. First the univariate scores: S approximates the drop in the objective on one degree of freedom, so
S = 102.6 for VWT is an expected fall of about 103 units, and 0.2 for CLSEX is nothing. The p-values are adjusted
for six simultaneous tests (bh, Benjamini–Hochberg). Second the stepwise selection: at each step the best remaining
candidate is tested conditionally, given those already selected. VWT enters first, then CLWT, then CLEGFR; the fourth,
VSEX, would have a conditional p of 0.055, above 0.05, so the selection stops. Third, the joint refit of the
retained effects, with all base parameters re-estimated: the OFV falls from −2880.213 to −3139.705, 259.5 units.
The result, as printed at the end of the run:
Candidate results (frozen-model efficient score; the chosen equation of each pair):
candidate S(univ) df p(univ) p(adj) S(cond) p(cond) step beta SE class
V~WT:power 102.645 1 4.009e-24 2.406e-23 102.645 4.009e-24 1 1.02884 0.10155 retained
CL~WT:power 67.533 1 2.072e-16 6.215e-16 34.274 4.787e-9 2 0.73827 0.12611 retained
CL~EGFR:power 25.463 1 4.510e-7 9.020e-7 29.127 6.778e-8 3 0.64532 0.11957 retained
CL~CRCL:power 22.935 1 1.676e-6 2.514e-6 2.609 1.062e-1 - 0.47238 0.09864 uncertain
V~SEX:proportional 1.231 1 2.671e-1 3.206e-1 3.697 5.450e-2 - 0.05540 0.04993 rejected
CL~SEX:proportional 0.201 1 6.542e-1 6.542e-1 0.869 3.513e-1 - -0.02866 0.06398 rejected
Final covariate model (joint refit: OFV -3139.705, 259.49 below the base model's -2880.213):
CL = TVCL × (WT/71.56)^1.034 × (EGFR/96.15)^0.5876
V = TVV × (WT/71.56)^0.9343
Reading the classes. Each pair ends in one of three classes.
- Retained: selected by the stepwise procedure and kept by a backward check. CL
WT, CLEGFR and V~WT. - Rejected: neither significant on its own nor selected conditionally. CL
SEX and VSEX. - Uncertain: significant on its own, but not once a correlated competitor is in the model. CL~CRCL: its univariate p (2.5e-6) is strong, its conditional p given EGFR is 0.106. This is the finding that the checks of Section 3.2 foretold: CRCL and EGFR carry the same signal, and the data cannot say which is the cause. The program says uncertain, not no.
Compare with the truth of Section 3.1. The three relationships that were simulated are the three retained; SEX, which
was simulated as null, is rejected on both parameters; and CRCL, the proxy, is uncertain rather than selected. The exponent
estimates are 0.59 for EGFR (true 0.6) and 0.93 for VWT (true 1.0). The estimate for CLWT is 1.03 (SE 0.085), higher than
the 0.75 used to simulate; the one-step estimate before the refit was 0.74. One dataset of 200 subjects is one draw, and the
two weight effects, on clearance and on volume, are not independent in an oral model, so a single exponent is estimated
with more uncertainty than its standard error suggests. How often the engines recover the truth over many datasets is what
simulate-study measures (Chapter 29).
The draft control stream. cov writes draft_model.ctl: the base control stream with the retained effects coded in,
the MU-referencing preserved, and three new $THETA records with the refit estimates as initial values. The inserted
lines are:
; nlmx (frozen): CL~WT:power
MU_1 = MU_1 + THETA(6)*LOG(WT/71.56)
; nlmx (frozen): CL~EGFR:power
MU_1 = MU_1 + THETA(7)*LOG(EGFR/96.15)
; nlmx (frozen): V~WT:power
MU_2 = MU_2 + THETA(8)*LOG(WT/71.56)
$THETA ; nlmx: retained covariate effects
1.033592 ; CL~WT:power (nlmx joint virtual refit)
0.587554 ; CL~EGFR:power (nlmx joint virtual refit)
0.934289 ; V~WT:power (nlmx joint virtual refit)
The header of the file says it plainly: DRAFT … UNCONFIRMED: every inserted relationship must be confirmed by a NONMEM fit. A draft is a starting point for the confirmatory run, not a result.
3.5.2 Refit with the retained effects
The confirmatory step is a fit. The tour copies the draft to a new run and fits it with fit:
sed 's/run101/run102/' out_frozen/draft_model.ctl > models/run102.ctl
nlmx fit models/run102.ctl -o out_fit102
(The sed renames the run inside the file, including in the comment that records where the draft came from.)
0.04s info initial OFV -3070.8952
2.74s ok OFV -3139.7047 after 10 iteration(s), 231 function evaluations — relative OFV change below 1.0e-9 for 3 iterations
4.17s ok covariance step complete; condition number of the correlation matrix 2.870e0
…
THETA(6) CL~WT:power (nlmx joint… 1.03359 0.0845587 8.2 [0.867859, 1.19932]
THETA(7) CL~EGFR:power (nlmx joint… 0.587558 0.0708674 12.1 [0.448661, 0.726456]
THETA(8) V~WT:power (nlmx joint… 0.934294 0.080612 8.6 [0.776297, 1.09229]
OMEGA(1,1) CL (iiv) 0.0921313 0.00993236 10.8 [0.0726642, 0.111598] 31.0659 CV% 3.0
OMEGA(2,2) V (iiv) 0.0550196 0.00641328 11.7 [0.0424498, 0.0675894] 23.7826 CV% 5.9
The OFV of the full fit, −3139.7047, is the value the joint virtual refit of cov had predicted (−3139.705): the shortcut and
the real fit agree. And the between-subject variability fell, as it should when covariates explain part of it: the
coefficient of variation of clearance from 45 % to 31 %, and that of volume from 34 % to 24 %.
3.5.3 forest: the effects, with their uncertainty
An exponent is hard to interpret; a ratio is not. The forest plot shows, for each effect, the ratio of the parameter at a low and a high covariate value to its value for the reference subject, with a confidence interval.
nlmx forest models/run102.ctl --results-dir out_fit102 --forest-covariates WT,EGFR --plots -o out_forest
The --results-dir option points to the folder with the .ext and .cov of the refit. The console gives the numbers behind the
plot:
CL (typical value 3.34): ratio to the reference, median of draws and 90% CI
WT
48.4 (5th) 0.67 [0.63, 0.71] outside the band *
108 (95th) 1.53 [1.45, 1.62] outside the band *
EGFR
60 (5th) 0.76 [0.72, 0.80] overlaps the band
152 (95th) 1.31 [1.24, 1.38] overlaps the band
Variability
BSV (90% of subjects) [0.61, 1.65]

How to read Figure 3.5.1: the dashed line at 1 is the reference subject (median weight 71.6 kg, median EGFR 96.2). The grey band, 0.8 to 1.25, is the conventional range of "no relevant difference". A light subject (48 kg, the 5th percentile) has about two-thirds of the typical clearance and volume, a heavy one (108 kg) about one and a half times; the whole interval of each lies outside the band, so the weight effects are potentially relevant. The renal effect on clearance is smaller: the intervals touch the band. The orange bars give the between-subject variability left after the covariates, for scale: the 90 % of subjects range from 0.61 to 1.65 times the typical clearance, which is wider than the covariate effects. This is the picture that goes into a report. Chapter 26 describes the layouts, the exposure sections and the options.
3.5.4 vpc: does the model reproduce the data?
A predictive check simulates the dataset many times from the model and compares the observed percentiles with the
simulated ones. nlmx.vpc, which generate wrote, asks for a prediction-corrected VPC (pcVPC) of the base model,
stratified on weight:
[inputs]
control_stream = "models/run101.ctl"
[vpc]
type = "pcvpc"
samples = 500
stratify_on = ["WT"] # the base model has no WT effect: the strata show it
stratify_groups = 2
nlmx vpc -c nlmx.vpc --plots -o out_vpc
0.01s ok 2000 observations in 2 stratum/strata, 20 bins
0.46s ok 500 replicates × 2000 observations simulated
0.71s ok 5 publication plot(s) in plots/ (png 7×5 in, 2100×1500 px at 300 dpi)
26 of 30 observed percentiles lie outside their simulated 95% CI (marked *) ← WT<71.56
20 of 30 observed percentiles lie outside their simulated 95% CI (marked *) ← WT≥71.56
0.71s ok pcVPC complete — 46 of 60 observed percentiles outside their 95% CI
The check fails as designed: 46 of 60 observed percentiles (the 5th, 50th and 95th in each of ten bins, in two weight strata) lie outside the 95 % interval of the simulated ones. The numerical predictive check says the same thing in a table: in the lighter half, 69.8 % of the observations are above the median prediction, instead of 50 %. A model that ignores weight over-predicts for the light and under-predicts for the heavy, and the strata make this visible. Run the same check on the model with the retained effects:
nlmx vpc models/run102.ctl --results-dir out_fit102 --vpc-type pcvpc --samples 500 --stratify WT --stratify-groups 2 --plots -o out_vpc102
2 of 30 observed percentiles lie outside their simulated 95% CI (marked *)
0 of 30 observed percentiles lie outside their simulated 95% CI (marked *)
1.63s ok pcVPC complete — 2 of 60 observed percentiles outside their 95% CI

Figure 3.5.2 shows the heavier half. The solid line is the observed median, the dashed lines the observed 5th and 95th percentiles, the shaded bands the 95 % intervals of the same percentiles from the 500 simulated datasets, and circles mark observed percentiles outside them. Left, the base model: the observed percentiles lie systematically below the simulated bands, and most are circled. Right, with the covariate effects: the observed lines run inside their bands, and 2 of 60 percentiles are outside, which is about what chance gives at a 95 % level for 60 comparisons (about 3). This pair of pictures is the case for the covariate model, and a good example of why a predictive check is run on the final model and not only on the base model (Chapter 27).