8.12 Subject timelines and record execution
Model execution is subject-by-subject and record-by-record. Local variables reset at the beginning of a subject, then persist across its records. NEWIND is 1 for the first record and 2 thereafter; NDREC is the one-based record number within that subject.
For a compartment model, each record broadly follows this order:
- load record data and effective ETAs;
- execute
$PKand rebuild parameters/system if required; - initialise
A_0on the first record, or advance state to record time; - apply reset semantics for
EVID=3/4; - process a dose and schedule ADDL events;
- select the observation/output compartment and compute
F; - execute
$ERRORwhen required; - apply negative-CMT turn-off after prediction.
Pending lagged doses, infusion stops and MTIME crossings are processed during advancement. Events exactly at the target time are included before the record's prediction according to the engine's event ordering.
Time-varying parameters
$PK is evaluated at every record. Its resulting parameters govern the interval that ends at that record, matching the engine's intended NONMEM default semantics. Covariates carried on records can therefore change interval dynamics. Sparse change-point records and observation records must be ordered and populated consistently.
Time reversal and resets
Ordinary records cannot move backward in time. A reset/reset-dose record (EVID=3/4) can establish a new time origin; the engine resets amounts, infusions, pending events, output accounting and model-event flags, then reapplies A_0.
$PRED path
$PRED has no compartment timeline. It evaluates the prediction block on eligible records using data, parameters and local state. Event columns can still be inputs to its code, but no PREDPP amount system is advanced.
Common mistakes
- Assuming parameters at the start rather than end record govern an interval.
- Omitting covariate values on event/change records.
- Sorting reset segments as one monotone global timeline.
Checklist
- Draw the exact subject event order.
- Mark every
$PKreevaluation and parameter change. - Test tied times, reset segments and first-record initialization.
Further reading
See dose and infusion events, steady state and resets and Chapter 6's record semantics.