Documentation

5.3 Writing NONMEM-format output

nlmx writes a run family that uses familiar NONMEM suffixes and labels. The purpose is inspection, reuse by nlmx and controlled interchange. The files are deterministic formatted exports; they are not a claim that NONMEM itself produced the run.

5.3.1 The fitted run family

The Chapter 5 fit writes these central artifacts under documents/ch05/results/fit/:

Artifact Role
base.ctl control stream rewritten with fitted parameter values and a usable data reference
base.ext estimates, objective and special result rows
base.cov covariance of estimated population parameters
base.cor standard errors on the diagonal and correlations off diagonal
base.phi subject-level ETA and conditional-covariance information
fit_summary.json / fit_summary.txt machine- and human-readable nlmx fit summaries
diagnostic CSV files predictions, residuals and related nlmx outputs

The exact inventory depends on the command, options and whether a covariance step succeeds. A .lst listing is not produced as a substitute for the nlmx summaries. Likewise, source $TABLE FILE= directives do not define the complete output inventory of an nlmx fit.

The command used for the fixture is:

nlmx fit documents/ch05/base.ctl `
  --keep-predose `
  --output documents/ch05/results/fit

The complete captured console output is in documents/ch05/results/logs/fit.txt.

5.3.2 Numeric formatting

The .ext and labelled matrix writers use scientific notation with enough digits for interchange and replay. Rewritten control-stream initial estimates use a compact significant-digit representation. These two forms serve different jobs: results files carry numerical output, while the control stream remains readable and executable.

That distinction means a text diff of two rewritten control streams is not a high-precision equality test. Compare parsed parameter vectors or .ext values for numerical regression. For a round trip, define tolerances before looking at the outcome and compare objective, predictions and covariance structure as appropriate.

Fixed parameters can appear in .ext with sentinel standard-error information rather than an estimated uncertainty. Do not turn such a placeholder into a confidence interval. The .cov and .cor matrices are restricted to the estimated-parameter space and are the authoritative uncertainty artifacts when present and valid.

5.3.3 What is preserved and what is normalised

nlmx aims to preserve model meaning for the supported subset. It can rewrite parameter estimates into the control stream, retain comments associated with supported parameter structures, and keep explicit SAME blocks. It also normalises spacing, number formatting and supported alternate covariance parameterisations.

An input such as BLOCK(2) SD CORRELATION is represented internally in covariance units and may be written in that natural form. Cholesky inputs are similarly converted. This is a semantic conversion, so the validation question is whether the resulting covariance matrix agrees, not whether the lines are identical.

Preservation has limits:

  • unsupported records cannot be made operative by retaining their text;
  • arbitrary external code and vendor extensions are not executable nlmx model statements;
  • very large bounds can be represented as unbounded on rewrite;
  • structural zero and fixed-block edge cases require direct inspection in 4.3.0;
  • the data path can be rewritten so that the emitted control stream remains usable from its output location;
  • output tables are chosen by nlmx rather than by a promise to reproduce every source $TABLE file.

Archive the original control stream beside the analysis record. The rewritten control stream is the model nlmx used or produced; it should not overwrite the provenance copy.

5.3.4 Using output in another program

Before importing nlmx output into NONMEM, PsN, R or another tool:

  1. identify nlmx as the producer and record its version;
  2. inspect all warnings and the effective estimation method;
  3. verify the $DATA location and any ignore/accept behavior;
  4. compare parameter labels, fixed flags, bounds and covariance blocks;
  5. verify the .cor diagonal convention expected by the consumer;
  6. run a no-estimation or low-cost evaluation before launching a long fit;
  7. preserve both programs' logs and numerical outputs.

PsN's update_inits serves a related workflow—moving final estimates into initial values—but its behavior and supported file conventions belong to PsN. A file that is useful to both programs still needs a cross-tool test. See the htmlPsN documentation for the installed PsN version.

Assumptions and limits

The writer assumes that the internal nlmx model can be represented in the supported control-stream subset. NONMEM-format output is an interchange aid, not a certification mark. Formal equivalence requires a reference executable, prespecified cases and tolerances, which Chapter 42 will define.

Common mistakes

  • Calling nlmx-produced files “NONMEM results” without naming the producer.
  • Comparing rounded control-stream values when full-precision .ext values are available.
  • Reading a fixed-parameter standard-error sentinel as an estimate.
  • Overwriting the original control stream with a rewritten one.
  • Assuming source $TABLE filenames will be emitted by fit.

Checklist

  • Producer, version and executable hash were recorded.
  • Original and rewritten control streams are both retained.
  • Data paths and parameter blocks were reviewed.
  • The uncertainty matrix dimension matches estimated parameters.
  • Downstream software received a documented .cor convention.
  • A small cross-tool evaluation passed before expensive work began.

Further reading

Section 5.4 explains how nlmx chooses among run families. Section 5.5 shows two numerical checks. Chapter 10 will inventory reports and figures, while Chapter 38 will be the complete output-file reference.