Tutorials › Nonlinear Mixed-Effects Models (NLME) › Ordered Categories as Trend Effects

Functional Forms for Covariates · Tutorial 501 of 797

Ordered Categories as Trend Effects

You will compare indicator and numeric trend coding, identify the scale on which a trend is linear, and calculate the implied parameter effects for ordered categories.

Intermediate 10 min read

What You'll Learn

  • Write indicator-coded and numeric trend models for an NLME parameter.
  • Interpret a trend coefficient on the chosen parameter scale.
  • Calculate category-specific typical parameter values and contrasts.
  • Identify the equal-increment assumption imposed by numeric scores.
  • Recognize when arbitrary indicator effects do not follow a linear trend.
  • Diagnose and describe limitations of trend coding.

Why Represent Ordered Categories With a Trend?

Some covariates have categories with a natural order: for example, mild, moderate, and severe disease, or successive stages of renal impairment. Treating these categories as nominal is flexible, but it does not use their order to summarize a pattern. Numeric trend coding uses the order by assigning each category a score, then describes the covariate effect with a slope across those scores. The benefit is parsimony; the cost is a substantive assumption about how effects change from one category to the next.

In an NLME model, the trend is specified for a model parameter, not automatically for the observed response. For example, a trend in clearance changes the clearance used by the structural model; it does not assert that concentrations change linearly across category scores. The parameter scale matters: a linear trend in clearance differs from a linear trend in log clearance.

Definition: Let an ordered categorical covariate have \(K\) levels, indexed \(c=1,\ldots,K\), and assign level \(c\) a numeric score \(x_c\). A numeric trend effect on a transformed NLME parameter \(g(\theta_i)\) is a model in which the category contributes \(\beta_1 x_{c_i}\), where \(c_i\) is the category for individual \(i\). The score values and the transformation \(g\) define the scale and increments to which the trend assumption applies.

Indicator Coding and Trend Coding

With indicator coding, choose category 1 as the reference and give each other category its own coefficient. A standard form for one parameter is

$$ g(\theta_i)=\beta_0+\sum_{c=2}^{K}\gamma_c I(c_i=c)+\eta_i. $$

Here \(I(c_i=c)\) is 1 when individual \(i\) is in category \(c\), and 0 otherwise. The reference category has transformed typical parameter value \(\beta_0\); category \(c\) has transformed typical value \(\beta_0+\gamma_c\). Indicator coding does not require the category effects to follow a particular pattern.

Numeric trend coding instead uses one slope:

$$ g(\theta_i)=\beta_0+\beta_1x_{c_i}+\eta_i. $$

For the examples here, the random effect \(\eta_i\) has mean zero, the same distribution across categories, and is independent of category. These assumptions mean that setting \(\eta_i=0\) gives the typical parameter value in each category. The trend describes that typical value; it does not remove individual variation or specify the residual-error model.

Subtracting the transformed typical value for category \(d\) from that for category \(c\) gives

$$ \left[\beta_0+\beta_1x_c\right]-\left[\beta_0+\beta_1x_d\right] =\beta_1(x_c-x_d). $$

Thus, category effects are equally spaced on the \(g(\theta)\) scale when the scores are equally spaced. With scores \(0,1,2,\ldots\), each one-point increase adds \(\beta_1\) on that scale. If \(g\) is the identity function, this means equal additive changes in the parameter. If \(g(\theta)=\log(\theta)\), it means equal changes in log parameter, or equal multiplicative ratios in the parameter.

Key constraint: With \(K\) categories and equally spaced scores, trend coding has an intercept and one slope, while reference-cell indicator coding has an intercept and \(K-1\) category effects. For \(K\geq 3\), the trend model imposes \(K-2\) constraints on the indicator effects: those effects must lie on a straight line against the assigned scores. For two categories, one slope can represent the single difference, so the two parameterizations are equivalent apart from score scaling.

Calculating Effects on Different Parameter Scales

Worked Example: An Additive Trend in Clearance

Suppose a hypothetical NLME model uses severity scores 0, 1, 2, and 3 for four ordered categories. Clearance \(CL_i\), measured in L/h, has an identity-scale trend with \(\beta_0=5.00\) L/h and \(\beta_1=-0.400\) L/h per score point. For the typical individual, \(\eta_i=0\), so

$$ CL_{\mathrm{typ}}(c)=5.00-0.400x_c\ \mathrm{L/h}. $$

The category-specific typical clearances are:

  • Score 0: \(5.00-0.400(0)=5.00\) L/h.
  • Score 1: \(5.00-0.400(1)=4.60\) L/h.
  • Score 2: \(5.00-0.400(2)=4.20\) L/h.
  • Score 3: \(5.00-0.400(3)=3.80\) L/h.

The model therefore assigns a decrease of 0.400 L/h for each one-point score increase. For example, the typical contrast between scores 0 and 3 is \(3(-0.400)=-1.20\) L/h, and \(5.00-1.20=3.80\) L/h. This is an additive pattern in clearance, not a claim that the observed concentration changes by a fixed amount.

Worked Example: A Multiplicative Trend in a Parameter

Consider three hypothetical ordered categories scored 0, 1, and 2. Suppose a parameter \(\theta_i\), measured in L/h, is modeled on the log scale:

$$ \log(\theta_i)=\log(5.00)+\log(0.800)x_{c_i}+\eta_i. $$

At \(\eta_i=0\), exponentiating gives \(\theta_{\mathrm{typ}}(c)=5.00(0.800)^{x_c}\) L/h. The values are:

  • Score 0: \(5.00(0.800)^0=5.00\) L/h.
  • Score 1: \(5.00(0.800)^1=4.00\) L/h.
  • Score 2: \(5.00(0.800)^2=3.20\) L/h.

Each one-point score increase multiplies the typical parameter by 0.800, corresponding to a 20.0% decrease relative to the preceding category. The two-point contrast is a ratio of \(0.800^2=0.640\), so the score-2 typical value is 64.0% of the score-0 value. It is not a constant additive decrease: the decreases are 1.00 L/h and then 0.800 L/h.

How the Trend Restricts Indicator Effects

The restriction can be seen directly by rewriting the trend model in reference-cell form. If scores are \(x_1=0,x_2=1,\ldots,x_K=K-1\), then category \(c\)'s indicator coefficient on the transformed scale must equal \(\beta_1x_c\). In particular, the second category's effect is \(\beta_1\), and the third category's effect is \(2\beta_1\). An arbitrary set of indicator coefficients will not generally satisfy these equalities.

Worked Example: Checking Whether Indicator Effects Follow a Trend

Suppose a hypothetical model uses log parameter effects and has three ordered categories scored 0, 1, and 2. An indicator-coded model estimates a typical parameter of 6.00 L/h in the reference category, with log-scale coefficients \(\gamma_2=-0.100\) and \(\gamma_3=-0.350\). The typical parameter values implied by these estimates are:

  • Category 1: \(6.00\) L/h.
  • Category 2: \(6.00\exp(-0.100)=5.429\) L/h.
  • Category 3: \(6.00\exp(-0.350)=4.228\) L/h.

For a one-slope trend on these scores, the category-2 effect would be \(\beta_1\), and the category-3 effect would have to be \(2\beta_1\). If \(\beta_1=-0.100\), the category-3 effect required by the trend would be \(-0.200\), not \(-0.350\). Conversely, setting \(\beta_1=-0.350/2=-0.175\) to match category 3 would imply a category-2 effect of \(-0.175\), not \(-0.100\). These indicator effects therefore do not lie on a straight line across the assigned scores. The indicator model can represent them; a linear trend model cannot represent both exactly.

Choosing Scores, Checking Fit, and Understanding Limits

Ordinal labels establish order, but they do not by themselves establish equal spacing. Assigning scores 0, 1, 2 assumes that the modeled effect changes by the same amount from the first to the second category as from the second to the third, on the chosen parameter scale. If scientifically justified spacing differs, scores such as 0, 1, 3 can encode that spacing; the model then assumes a change three times as large between scores 0 and 3 as between scores 0 and 1. The scores should be chosen for a defensible reason, not because numeric labels happen to exist.

A trend model is attractive when a monotone, approximately linear pattern is scientifically credible and the data do not support many separate category effects. It uses fewer fixed-effect coefficients than indicator coding and can be more stable when some categories are sparse. Indicator coding is preferable when category-specific departures are plausible or when the order is meaningful but spacing is not. As in the earlier material on categorical covariates, these are alternative parameterizations of the covariate effect, not different definitions of the underlying categories.

Assess the assumption on the scale actually modeled. Useful checks include plotting category-specific model estimates or predictions against the assigned scores, inspecting whether deviations from a straight line are systematic, and checking whether estimates are imprecise because some categories contain little information. In an NLME analysis, observed response summaries alone may not reveal the parameter pattern: response depends on the structural model, other covariates, dosing, sampling, and random effects. Use model-based parameter or response diagnostics appropriate to the fitted model.

A trend can also be misleading if it is extrapolated beyond observed categories, if a category score is miscoded, or if the effect changes direction across levels. A linear identity-scale trend can imply impossible values outside the observed score range, such as negative clearance. A log-scale trend guarantees positive parameter values but still imposes a constant ratio per score point. Neither coding resolves confounding, sparse data, or misspecification elsewhere in the NLME model.

Common pitfall: “The categories are ordered, so coding them 1, 2, and 3 only uses their order.” This is incorrect: a one-slope model also treats the step from 1 to 2 as equal to the step from 2 to 3 on the modeled scale. The correction is to state the score assignment and scale explicitly, justify the implied increments, and compare the trend's restrictions with the scientific question and category-specific evidence.
1
Define the category scores.
Record the ordered levels and the numeric score assigned to each; do not assume ordinal labels imply equal spacing.
2
Specify the parameter scale.
State whether the trend is additive in the parameter, additive in its log, or linear on another chosen transformed scale.
3
Translate the slope into category effects.
Calculate each typical value and relevant contrast, then check units and whether the implied pattern is scientifically plausible.
4
Examine the restriction.
Ask whether the category effects plausibly follow the imposed straight line; use indicator coding when unrestricted category-specific effects are needed.

Check Your Understanding

Answer the questions, then compare your work with the solutions.

  1. For scores 0, 1, and 2, what does an identity-scale slope of 0.30 units per score point imply for the contrast between scores 0 and 2?
  2. A log-scale trend has \(\beta_1=\log(1.10)\). What is the multiplicative change for a three-point score increase?
  3. With four equally spaced categories, how many fixed-effect coefficients are used by reference-cell indicator coding and by a one-slope trend model, including the intercept?
  4. For scores 0, 1, and 2, indicator effects on the modeled scale are \(\gamma_2=-0.20\) and \(\gamma_3=-0.50\). Can a one-slope trend represent both exactly? Explain.
  5. Why is it not enough to say that numeric coding is appropriate simply because category labels are ordered?

Solutions. (1) The contrast is \(0.30(2-0)=0.60\) units; the typical value at score 2 is 0.60 units above that at score 0. (2) The ratio is \(\exp(3\beta_1)=\exp(3\log(1.10))=1.10^3=1.331\), a 33.1% increase relative to the score-0 value. (3) Indicator coding uses \(1+(4-1)=4\) coefficients; trend coding uses 2, an intercept and a slope. (4) No. Matching category 2 requires \(\beta_1=-0.20\), which predicts \(\gamma_3=2\beta_1=-0.40\), not \(-0.50\). (5) Numeric trend coding additionally assumes equal score increments and a straight-line effect on the specified parameter scale; ordering alone does not justify those assumptions.