NONMEM cheat sheet
A concise, accurate reference for NM-TRAN control streams — the blocks, ADVAN/TRANS subroutines, estimation methods, error models, and dataset items you use across the course. Every fact here is what the lessons teach and the engine runs.
Control-stream blocks
An NM-TRAN control stream is a sequence of $-records. A minimal PK run needs
$PROBLEM, $INPUT, $DATA, a structural model, $THETA/$OMEGA/$SIGMA, and $ESTIMATION.
| Block | Purpose |
|---|---|
$PROBLEM | Free-text title for the run. |
$INPUT | Names the columns of the data file, in order (e.g. ID TIME AMT DV MDV EVID). |
$DATA | Path to the dataset; IGNORE=@ skips header/alpha rows. |
$SUBROUTINES | Selects the structural model, e.g. ADVAN2 TRANS2 (or ADVAN6/8/13 for $DES). |
$MODEL | Defines compartments for general (ADVAN5/6/7/…) models. |
$PK | Computes PK parameters (CL, V, KA…) from THETA/ETA and covariates. |
$DES | ODE right-hand sides (DADT(i)) for differential models. |
$ERROR | Links the prediction F to the observation Y via EPS (residual error). |
$THETA | Fixed-effect initial estimates (typical values), with optional bounds and FIX. |
$OMEGA | Variance–covariance of the ETAs (between-subject variability). |
$SIGMA | Variance of the EPSs (residual error). |
$ESTIMATION | Chooses the method (METHOD=COND, INTER, LAPLACIAN, SAEM…) and controls. |
$COVARIANCE | Requests standard errors / the covariance step. |
$TABLE | Writes requested columns (PRED, IPRED, CWRES, ETAs…) for diagnostics. |
ADVAN / TRANS quick reference
ADVAN picks the structural model; TRANS picks the parameterization it expects. Closed-form
ADVANs are fast; ADVAN6/8/13 integrate $DES ODEs numerically.
| ADVAN | Model | Typical TRANS & parameters |
|---|---|---|
ADVAN1 | 1-cmt, IV | TRANS2: CL, V |
ADVAN2 | 1-cmt, first-order absorption | TRANS2: CL, V, KA (depot = cmt 1) |
ADVAN10 | 1-cmt, Michaelis–Menten elimination | VM, KM, V |
ADVAN3 | 2-cmt, IV | TRANS4: CL, V1, Q, V2 |
ADVAN4 | 2-cmt, first-order absorption | TRANS4: CL, V2, Q, V3, KA |
ADVAN11 | 3-cmt, IV | TRANS4: CL, V1, Q2, V2, Q3, V3 |
ADVAN12 | 3-cmt, first-order absorption | TRANS4 + KA |
ADVAN5 / ADVAN7 | General linear (any compartment layout) | Rate constants K12, K21, … via $MODEL |
ADVAN6 / ADVAN8 / ADVAN13 | General nonlinear ODE | $DES with DADT(i); 6 non-stiff (DVERK), 8 stiff (Gear), 13 (LSODA) auto-switches — the robust default |
With TRANS1 you supply micro-constants directly (K, K12, K21…) instead of clearances.
Scaling: define S1=V (or S2=V2) so concentration = amount ÷ volume.
$PK parameters & a canonical deck
Reserved names
CL, V, V1, V2, V3, Q, Q2, Q3, KA— disposition parametersS1, S2, S3— scaling (amount → concentration) per compartmentF1, D1, R1, ALAG1— bioavailability, infusion duration, rate, lag time for compartment 1KE0— effect-compartment equilibration rate
Individual-parameter form
- Log-normal (default):
CL = THETA(1)*EXP(ETA(1)) - Additive:
P = THETA(1) + ETA(1) - Proportional/CV:
P = THETA(1)*(1+ETA(1)) - Allometric covariate:
CL = THETA(1)*(WT/70)**THETA(3)*EXP(ETA(1))
; 1-compartment oral popPK, first-order absorption $SUBROUTINES ADVAN2 TRANS2 $PK CL = THETA(1)*EXP(ETA(1)) V = THETA(2)*EXP(ETA(2)) KA = THETA(3)*EXP(ETA(3)) S2 = V ; central cmt is #2 in ADVAN2 $ERROR IPRED = F Y = IPRED*(1 + EPS(1)) + EPS(2) ; combined error
Estimation methods
Set on $ESTIMATION. INTER adds eta–epsilon interaction (turns FOCE into FOCEI) —
it is never automatic and matters when the residual variance depends on the prediction.
| Method | What it is | When |
|---|---|---|
METHOD=ZERO (FO) | First-order; linearizes at ETA=0 | Fast, rough starting fit |
METHOD=COND (FOCE) | Conditional; linearizes at each subject's ETA | Workhorse for continuous data |
METHOD=COND INTER (FOCEI) | FOCE + eta–epsilon interaction | Proportional/combined error models |
METHOD=COND LAPLACIAN | Second-order Laplace approximation | Non-normal / categorical / count likelihoods |
METHOD=SAEM | Stochastic approximation EM (Monte-Carlo) | Complex / multimodal, many random effects |
METHOD=IMP | Importance sampling | Objective refinement, often after SAEM |
Residual error models
Written in $ERROR, linking prediction F to observation Y through EPS (whose variance lives in $SIGMA).
| Model | $ERROR |
|---|---|
| Additive | Y = F + EPS(1) |
| Proportional | Y = F*(1 + EPS(1)) |
| Combined | Y = F*(1 + EPS(1)) + EPS(2) |
| Log / exponential | Y = LOG(F) + EPS(1) (with log-transformed DV) |
Noncontinuous & general-likelihood models
Categorical, count and time-to-event data have no residual EPS. Set F_FLAG=1 and make Y the likelihood of the observed record, then fit with $ESTIMATION METHOD=COND LAPLACIAN (the Laplace approximation to the exact likelihood).
| Data type | How Y is built (with F_FLAG=1) |
|---|---|
| Binary (logistic) | P = EXP(LP)/(1+EXP(LP)); Y = DV*P + (1-DV)*(1-P) |
| Count (Poisson) | Y = Poisson probability of DV given mean LAM (e.g. Y = EXP(-LAM)*LAM**DV/EXP(GAMLN(DV+1))) |
| Ordered categorical | cumulative logits with monotone cut-points; Y = P(observed level) as a difference of cumulative probabilities |
| Time-to-event | integrate the hazard to a cumulative hazard CUMHAZ in $DES; SUR=EXP(-CUMHAZ); event record Y = HAZ*SUR, censored record Y = SUR |
| Below-LOQ (M3) | for BLQ=1 records, Y = PHI((LLOQ - IPRED)/W) — the probability the observation is below the limit (censored likelihood) |
Random effects: $OMEGA & $SIGMA
$OMEGA (between-subject)
- Diagonal:
$OMEGA 0.09 0.09— independent ETAs - Correlated:
$OMEGA BLOCK(2) 0.09 0.01 0.09 - IOV (inter-occasion): repeat
$OMEGA BLOCK(1) 0.09then$OMEGA BLOCK(1) SAMEper occasion — one shared variance across occasions - An ETA's variance ≈ CV² for a log-normal parameter at small values
$SIGMA (residual)
- One EPS per error term:
$SIGMA 0.04 FIXa value to hold it constant:$SIGMA 1 FIX- Interaction (FOCEI) is what makes prediction-dependent SIGMA correct
Dataset items (reserved $INPUT names)
| Item | Meaning |
|---|---|
ID | Subject identifier (groups records into individuals). |
TIME | Time of the record. |
AMT | Dose amount (on dosing records). |
DV | Dependent variable — the observation. |
MDV | Missing DV flag: 1 on dose/other non-observation records. |
EVID | Event ID: 0 = observation, 1 = dose, 2 = other, 3 = reset, 4 = reset+dose. |
CMT | Compartment for the dose or observation. |
RATE | Infusion rate (or -1/-2 to estimate via R1/D1). |
SS | Steady-state flag (1 = dose to steady state). |
II | Interdose interval (used with SS and ADDL). |
ADDL | Number of additional identical doses. |
Dosing & steady state
- Bolus: a record with
AMT>0,EVID=1into the dosing compartment. - Infusion: add
RATE>0(or setRATE=-2and model durationD1). - Multiple doses:
ADDL=nwithII=τaddsnfurther doses everyτ. - Steady state:
SS=1withII=τstarts the subject at the steady-state profile for that regimen. - Lag / bioavailability:
ALAG1delays absorption;F1scales the dose reaching the systemic circulation.
Diagnostics
| Quantity | Meaning |
|---|---|
| OFV | Objective function value (−2·log-likelihood). Lower is a better fit; a drop of 3.84 for one added parameter is significant at p<0.05 (χ², 1 df). |
PRED / IPRED | Population / individual predictions. |
RES / WRES / CWRES | Residuals; CWRES (conditional weighted) is the modern standard for continuous data. |
NPDE | Normalized prediction distribution errors — simulation-based, should be N(0,1). |
| VPC | Visual predictive check: simulate from the model, compare observed vs simulated percentiles. |
| Shrinkage | High ETA/EPS shrinkage warns that individual estimates are pulled toward the population — read diagnostics with care. |
Common gotchas
- Forgetting
S2=V(ADVAN2/4) → predictions are amounts, not concentrations, and OFV is nonsense. - Using FOCE (no
INTER) with a proportional/combined error — addINTERso the interaction is accounted for. - Wrong TRANS for the ADVAN (e.g.
TRANS2params under a 2-cmtADVAN3). - Compartment mismatch: dosing into the wrong
CMT, or scaling the wrong compartment. - Over-parameterized
$OMEGA: too many random effects for the data → high shrinkage, unstable fits. - Categorical/count models need
LAPLACIANand anF_FLAGlikelihood, not the default normal residual.