Documentation

5.5 Round trips and worked conversions

Round trips are targeted regression checks. They can show that a specific export/import path preserves a specified numerical property. They do not prove general equivalence between programs or between every supported model.

5.5.1 Reproducing the chapter evidence

From the book root, run:

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

The script refuses a non-empty default results folder. This protects the recorded evidence. Use a new --output for an independent rerun, or archive and deliberately replace the canonical fixture in a reviewed documentation update.

The script records each command, exit code, the executable SHA-256, software version and key numerical differences in documents/ch05/results/example_summary.json. It fixes nlmx to one thread and uses deterministic generated data. Timestamps and executable hashes can differ across deliberate regenerations; prespecified numerical comparisons should remain within their tolerances.

The recorded 4.3.0 run produced:

Check First objective Second objective Absolute difference Declared tolerance Result
fitted .ext → zero-iteration replay -2880.2129561303 -2880.2129557331 3.97 × 10⁻⁷ 0.02 pass
covariance → SD/correlation -241.847377751872 -241.847377751872 1.71 × 10⁻¹³ 1 × 10⁻⁶ pass

These values are evidence for the bundled fixtures and executable hash in the summary file. They are not universal tolerances for other models.

5.5.2 Example 5.1: fitted estimates to a zero-iteration replay

The first run fits base.ctl and writes base.ext. A second run reads the fitted control stream, explicitly starts from the .ext, disables the covariance step and performs zero estimation iterations:

nlmx fit documents/ch05/results/fit/base.ctl `
  --start-from-ext `
  --ext documents/ch05/results/fit/base.ext `
  --max-iterations 0 `
  --no-cov-step `
  --keep-predose `
  --output documents/ch05/results/replay

The test compares the objective in the two fit_summary.json files with an absolute tolerance of 0.02. That tolerance is declared in the generator before results are presented. The replay checks parameter import, rewritten control-stream evaluation, data-path handling and objective evaluation. It does not rerun the optimizer and therefore does not test convergence-path reproducibility.

If the check fails, inspect in this order: effective dataset rows, parameter labels, parameter precision, likelihood/method, and model rewrite. Do not loosen the tolerance until the cause is understood.

5.5.3 Example 5.2: covariance versus SD/correlation

The second fixture uses two occasions and two explicitly dimensioned OMEGA blocks, the second declared SAME. One control stream specifies the first block in covariance units:

$OMEGA BLOCK(2)
0.09
0.018 0.04
$OMEGA BLOCK(2) SAME

The other uses SD/correlation input:

$OMEGA BLOCK(2) SD CORRELATION
0.3
0.3 0.2
$OMEGA BLOCK(2) SAME

Both commands use zero estimation iterations and no covariance step. Their objective functions are compared with an absolute tolerance of 1e-6. Equality here tests the parser's conversion to the same internal covariance matrix and evaluation at fixed population parameters. It is not an inferential fit and does not test uncertainty estimation.

The independently generated block.csv uses a one-compartment IV model and a fixed random seed. The script contains the full generating equations. Keeping data generation independent from the nlmx simulator makes the test less likely to reproduce the same implementation error on both sides.

5.5.4 What a stronger cross-software test adds

For a claim about reproducing major pharmacometrics software, extend these checks with:

  1. a versioned reference run produced by the external program;
  2. the same row set, event interpretation, units and missing-value rules;
  3. a parameter map including transformations, fixed flags and block order;
  4. prespecified tolerances for objective, gradients, estimates, standard errors, predictions and EBEs;
  5. cases that stress boundaries, repeated occasions, BLQ handling, correlated effects and numerical failure;
  6. independent review of discrepancies and a retained evidence bundle.

Speed should be measured only after the semantic comparison passes. Report wall time, hardware, thread count, compiler/build and stopping rules. An earlier stop or a simplified likelihood is a method difference, not a speedup of the same calculation.

Assumptions and limits

These examples cover one classical fit/replay path and one parameterisation conversion in nlmx 4.3.0. They do not cover SAEM, Laplace, ODE models, BLQ likelihoods, multi-level random effects or cross-vendor numerical agreement.

Common mistakes

  • Treating a round trip through the same codebase as independent validation.
  • Comparing optimizer endpoints without aligning stopping rules.
  • Reporting speed before confirming the same likelihood and data rows.
  • Using rounded control-stream values when a full-precision result is available.
  • Changing a tolerance after observing a discrepancy without documenting why.

Checklist

  • The tested property and tolerance were defined first.
  • Inputs, versions, hashes, thread counts and commands were recorded.
  • Data rows and parameter coordinates were aligned.
  • The result states what the test does and does not cover.
  • External validation uses an independently produced reference run.
  • Performance is compared only for matched work.

Further reading

Chapter 9 will cover numerical reproducibility and tolerances. Chapter 18 will define likelihood and estimation-method comparisons. Chapter 40 will catalogue differences from NONMEM, PsN, PopED and Monolix, and Chapter 42 will turn these principles into a formal validation matrix.