Documentation

22.10 Automatic covariate type detection

nlmx detects type from subject baseline values. Exactly two distinct values are binary. Three to five distinct whole-number values are categorical. Other patterns are continuous. Binary and categorical references default to the most frequent level; continuous references default to the median.

Automatic detection rules

Detection is a convenience, not a scientific definition. A dose group coded 1–4 may be categorical, ordinal, or a continuous dose depending on the question. A six-level category will not meet the automatic categorical rule. A biomarker rounded to five integers can be misclassified as categorical.

Review the number of distinct values, range, level counts, within-subject consistency, missingness, and units. Inspect output explicitly states detected types and references. Override when coding and meaning differ.

Baseline extraction deserves attention. A covariate intended as fixed should be constant or have a declared resolution rule. Time-varying covariates have method-specific handling. A text category may require numeric encoding supported by the dataset/control mapping; preserve a label dictionary.

Sparse levels create unstable categorical coefficients and can threaten convergence. Use min_level_subjects or revise grouping only with scientific justification, not after observing favorable results.

How to audit a detected type

Start from subject-level values, not the number of distinct cells in the longitudinal dataset. A binary covariate repeated over hundreds of observations is still binary; a nominal category coded 0, 1, 2 is not automatically ordinal; and a continuous laboratory value rounded to a handful of integers may still be continuous. Review labels, units, code lists, frequency tables, within-subject changes, and missing codes. Detection is a convenience for constructing a candidate equation, not a substitute for metadata. If the detected type changes after data cleaning, rerun the complete analysis because the generated columns, degrees of freedom, reference, and selection evidence may all change.

Common mistakes

  • Accepting automatic type without reviewing meaning.
  • Treating integer codes as inherently ordinal.
  • Ignoring within-subject changes in a baseline covariate.
  • Combining sparse levels only after seeing selection results.
  • Losing category-label provenance during numeric encoding.

Checklist

  • Review distinct values, range, counts, and units.
  • Decide continuous, binary, categorical, or ordinal scientifically.
  • Verify baseline/time-varying behavior.
  • Check level support and missingness.
  • Archive overrides and label mappings.

Further reading

See overrides and references, categorical equations, and time-varying covariates.