Documentation

6.9 Covariate type detection, levels and centring

Covariate modelling needs a type and reference before it needs a coefficient. nlmx can infer both from subject baseline values, but an accuracy-focused workflow should review and often declare them.

Figure 6.2. Covariate type detection and reference selection.

Figure 6.2. Automatic type detection uses distinct baseline values. The most frequent level becomes a categorical reference; a continuous reference defaults to the median unless configured otherwise.

Ordered covariate preparation pipeline

Figure 6.5. Detection, completion, transformation and centering are ordered operations. A change in order can alter both the analysis population and the values presented to the model.

The ordering is part of the analysis specification. Two tools can expose similarly named covariate options yet disagree because one detects type before filtering or calculates a median before applying its missing-value policy. Preserve intermediate counts and chosen reference values when validating equivalence.

Automatic type detection

For a covariate whose type is auto, nlmx 4.3.0 collects finite baseline values and distinct values, then applies:

  • exactly two distinct values → categorical (reported as binary);
  • integer-valued with no more than five distinct values → categorical;
  • otherwise → continuous.

This rule is deterministic, not semantic. A study arm numbered 1–6 becomes continuous by default; an integer laboratory value observed at only five values can become categorical. Declare --covariate-type or configuration when the scientific type is known.

Levels and reference

For non-continuous covariates, observed distinct values become levels when none are declared. The most frequent level becomes the reference. A configured reference must occur among declared levels or validation fails. Observed values outside declared levels also fail rather than silently becoming reference.

Ties in frequency depend on deterministic level traversal but should be avoided as an implicit scientific choice. State the reference level.

Continuous centring

Continuous relationships default to the median of the analysed subject values. mean and an explicit number are available. The reference affects parameter interpretation and numerical conditioning even when a correctly parameterised model can represent the same curve.

For a power relationship, the usual covariate ratio is based on COV/reference; therefore positive values are required for the standard power form. If auto-typed continuous values include zero or a negative number and forms were not explicitly chosen, nlmx removes the power form and records why.

Forms follow type

Default continuous and categorical forms are assigned after type inference. Binary covariates reduce redundant categorical equations because several parameterisations describe the same two-level contrast. Chapter 22 will derive the equations; here the important dataset contract is that type, levels and reference are part of the analysis input.

Assumptions and limits

Detection uses baseline values after missing policy and subject selection. A filter or dropped subject can change distinct counts, the median, the most frequent level and thus the candidate design.

Common mistakes

  • Treating an integer code as automatically categorical regardless of its levels.
  • Letting a six-arm study be inferred as continuous.
  • Accepting the most frequent level without clinical review.
  • Comparing coefficients from models centred at different references.
  • Filtering subjects without recording the changed centring value.

Checklist

  • Type is reviewed against scientific meaning.
  • Categorical levels and reference are explicit for final work.
  • Continuous reference is recorded numerically.
  • Power forms receive positive covariate values.
  • Type/reference are recalculated or fixed after population filters.

Further reading

Section 6.10 explains when the analysed baseline set changes. Chapter 22 will define every covariate equation and coefficient interpretation.