Documentation

6.16 Worked examples and reproducibility

The Chapter 6 evidence bundle exercises the data paths described in the preceding pages. It is pinned to nlmx 4.3.0 and records the executable SHA-256, commands and exit codes in jsonexample_summary.json.

Regenerating the bundle

From the book root:

python tools/ch06_examples.py `
  --nlmx path/to/nlmx.exe

The script writes only below documents/ch06 and refuses a non-empty results folder. It uses deterministic generation and one nlmx worker thread. Use a new --output for an independent rerun; replace the canonical evidence only as a reviewed documentation update.

Example 6.1: time-varying CRCL with ADDL/II

Eight subjects receive a dose at time 0 with ADDL=3 and II=12. Each has 12 observations and CRCL falls after hour 18. The zero-iteration fit reads 104 records: eight explicit doses and 96 observations. inspect with --covariates CL=CRCL identifies CRCL as time-varying.

Twenty-four observations occur exactly at an implied dose time. The log documents that the implied dose is given first. This is intentionally a teaching edge case; a production trough dataset should resolve pre/post-dose order explicitly.

nlmx fit documents/ch06/timevary.ctl `
  --max-iterations 0 --no-cov-step --keep-predose `
  -o documents/ch06/results/timevary-fit

nlmx inspect `
  --model-dir documents/ch06/results/timevary-fit `
  --run-stem timevary --covariates CL=CRCL
Figure 6.1. Explicit and implied events in the time-varying example.

Figure 6.1. One explicit record schedules three additional doses. An equal-time observation follows the implied dose; CRCL changes when a record carries its new value.

Example 6.2: BLQ data through QC, NCA and VPC

The deterministic oral dataset has 24 subjects, one dose each and eight observations each. Thirty-one of 192 observations are below LLOQ 0.7 and stored with a consistent BLQ flag.

nlmx qc-data documents/ch06/blq.csv `
  --lloq 0.7 --blq-flag BLQ `
  -o documents/ch06/results/qc-blq

nlmx nca documents/ch06/blq.csv `
  --lloq 0.7 --blq-flag BLQ `
  --blq-rule tmax-zero-missing --no-plots `
  -o documents/ch06/results/nca-blq

QC reports READY with no warnings. NCA analyses all 24 profiles, but finds a terminal slope in 13 after the BLQ rule. The documentation VPC uses the record-level LLOQ column, the flag and 30 replicates:

nlmx vpc documents/ch06/blq.ctl `
  --results-dir documents/ch06/results/blq-fit `
  --vpc-type vpc --samples 30 `
  --lloq LLOQ --blq-flag BLQ `
  --bins 0,0.5,1,2,4,8,12,24 --no-plots `
  -o documents/ch06/results/vpc-blq

Thirty replicates keep the example fast and reproducible; they are not recommended as a final-analysis replicate count.

Example 6.3: mutate before filter

The EDA example adds log concentration, normalised weight and period, then keeps only PK observation rows. It mutates 216 rows and analyses 192:

nlmx eda documents/ch06/blq.csv `
  --mutate "LNDV=log(DV); WT70=WT/70; PERIOD=ifelse(TIME<=4,1,2)" `
  --filter "EVID == 0 & DVID == 1" --no-plots `
  -o documents/ch06/results/eda-mutated

What the examples establish

They establish that these documented 4.3.0 paths execute with the bundled fixtures. They do not validate every event combination, censored likelihood, NCA convention or VPC implementation against external software. Formal validation requires independent reference outputs and prespecified tolerances.

Common mistakes

  • Editing generated fixtures without updating the generator.
  • Reusing the canonical results folder with --overwrite and losing provenance.
  • Treating 30 VPC replicates as final evidence.
  • Calling an internal executable example cross-software validation.

Checklist

  • Version and executable hash match the evidence summary.
  • Commands and exit codes are retained.
  • Fixture generation is deterministic and reviewable.
  • Documentation-scale settings are not reused blindly for final analysis.
  • External comparisons use independent outputs and tolerances.

Further reading

Chapter 7 will show how to move these commands into settings files. Chapter 9 will define reproducibility tests, and Chapter 42 will define the cross-software validation matrix.