Tutorials › Nonlinear Mixed-Effects Models (NLME) › Comparing Covariate Functions on a Shared Dataset

Functional Forms for Covariates · Tutorial 504 of 797

Comparing Covariate Functions on a Shared Dataset

Learn to compare covariate functions on the same data while tracking their predictions, interpretations, and boundary behavior.

Intermediate 10 min read

What You'll Learn

  • Compare additive, exponential, power, and piecewise-linear spline predictions on one dataset.
  • Interpret covariate effects in the units and scale of the modeled parameter.
  • Calculate predictions at an interior covariate value and compare their differences.
  • Explain why functions that fit similarly within the observed range may diverge near its boundaries.
  • Identify diagnostics and limitations that matter when choosing among candidate functions.

Why Compare Functions on the Same Data?

A covariate relationship can look convincing under more than one mathematical form. A straight-line increase, a constant proportional increase, a power relationship, and a flexible spline may all follow the same observed trend over a limited range. They need not imply the same parameter values between observations, or the same behavior at the edges of the data. Comparing functions on a shared dataset makes these differences visible.

The examples use a hypothetical pharmacometric setting in which body weight \(x\), measured in kilograms, is related to a typical clearance parameter \(\theta(x)\), measured in liters per hour. The values are illustrative, not from a real study. We compare functions fitted to the same seven observations; the goal is to examine what each functional form implies, not to declare one universally best.

Definition: A covariate function specifies how a model parameter \(\theta\) changes with a covariate \(x\). A fair functional-form comparison holds the dataset, response parameter, units, and reference value fixed, and compares the candidate functions over the same covariate range. A prediction is \(\theta(x)\), the value implied by a specified function at covariate value \(x\).

Earlier material on additive, exponential, power, and spline effects defines these forms individually. Here the emphasis is on how their predictions and interpretations compare when they are applied to identical data.

One Dataset, Four Candidate Functions

Suppose the hypothetical observations are as follows. The four prediction columns come from illustrative fitted functions. Values are rounded to three decimal places; calculations below use the displayed coefficients and unrounded function evaluations.

Weight \(x\) (kg)Observed clearance (L/h)Additive (L/h)Exponential (L/h)Power (L/h)Linear spline (L/h)
403.8003.6504.1763.8873.800
554.3004.3254.5704.4864.379
705.0005.0005.0005.0004.965
855.5005.6755.4715.4565.550
1005.9006.3505.9865.8715.885
1156.2007.0256.5506.2526.220
1306.4007.7007.1676.6066.400

All four predictions equal 5.00 L/h at the reference weight of 70 kg, except the illustrative spline, whose fitted value there is 4.965 L/h. The shared reference makes it easier to compare how each function changes away from 70 kg. The additive, exponential, and power examples are:

$$ \begin{aligned} \theta_{\mathrm{add}}(x) &= 5.00 + 0.0450(x-70),\\ \theta_{\mathrm{exp}}(x) &= 5.00\exp\{0.00600(x-70)\},\\ \theta_{\mathrm{power}}(x) &= 5.00\left(\frac{x}{70}\right)^{0.450}. \end{aligned} $$

The additive slope is 0.0450 L/h per kg: each additional kilogram adds the same amount to the predicted clearance. The exponential coefficient gives a constant change in log clearance per kilogram; it does not add a fixed amount to clearance. In the power function, the exponent 0.450 is the elasticity: locally, a 1% increase in weight corresponds to about a 0.450% increase in clearance.

Assumptions for this comparison: Each candidate is evaluated for the same positive parameter, covariate, units, and observations. The formulas are intended for the observed range of 40–130 kg unless their extrapolation is explicitly discussed. The observations and fitted functions are treated as illustrative; this table alone does not establish uncertainty, causal effects, or the adequacy of any model.

Worked Example: Comparing Predictions at 100 kg

At \(x=100\) kg, calculate the predictions from the additive, exponential, and power functions, then compare them with the observed clearance of 5.900 L/h.

Additive. Substitute \(x=100\) into the line:

$$ \theta_{\mathrm{add}}(100)=5.00+0.0450(100-70) =5.00+1.35=6.350\ \text{L/h}. $$

The additive prediction is 0.450 L/h above the observed value.

Exponential. Substitute into the exponential function:

$$ \theta_{\mathrm{exp}}(100) =5.00\exp\{0.00600(30)\} =5.00\exp(0.180) \approx5.00(1.19722) =5.986\ \text{L/h}. $$

This prediction is about 0.086 L/h above the observation.

Power. Substitute the weight ratio:

$$ \theta_{\mathrm{power}}(100) =5.00\left(\frac{100}{70}\right)^{0.450} \approx5.00(1.17410) =5.871\ \text{L/h}. $$

This prediction is about 0.029 L/h below the observation. At 100 kg, therefore, the exponential and power predictions are close, while the additive prediction is higher. This single comparison does not establish which function is preferable: the pattern across the range, model assumptions, uncertainty, and scientific plausibility also matter.

How the Interpretations Differ

The models can be compared by considering what they say about a change from the reference weight, not just by looking at a single predicted value. For the additive function, a 30 kg increase from 70 to 100 kg adds \(0.0450(30)=1.35\) L/h. For the exponential function, the ratio of the two predictions is:

$$ \frac{\theta_{\mathrm{exp}}(100)}{\theta_{\mathrm{exp}}(70)} =\exp\{0.00600(100-70)\} =\exp(0.180) \approx1.1972. $$

Thus, the exponential function predicts about 19.7% greater clearance at 100 kg than at 70 kg. For the power function, the ratio is \((100/70)^{0.450}\approx1.1741\), or about 17.4% greater. The models share the same reference prediction but imply different changes because their coefficients describe different scales.

A short derivative calculation explains the distinction. For the exponential function, differentiating with respect to weight gives:

$$ \frac{d\theta_{\mathrm{exp}}(x)}{dx} =0.00600\,\theta_{\mathrm{exp}}(x). $$

Its absolute increase per kilogram grows with the current predicted clearance, while its proportional increase per kilogram remains constant. For the power function, taking logarithms gives \(\log\theta=\log(5.00)+0.450\log(x/70)\). Differentiating with respect to \(\log x\) shows that \(d\log\theta/d\log x=0.450\), the constant elasticity. The additive function instead has the constant absolute slope \(d\theta_{\mathrm{add}}/dx=0.0450\) L/h per kg.

A spline can represent changing slopes, so its meaning is usually expressed through predicted values and local changes over specified intervals rather than one global slope or elasticity. For a transparent comparison here, the spline is a piecewise-linear function with knots at the seven observed weights. At those knots, its fitted predictions are the spline column in the table; between adjacent knots, it linearly interpolates the two endpoint predictions. This flexible illustrative fit is not a claim that seven knots are generally advisable.

Derivation: linear interpolation in one spline interval. Between adjacent knots \(x_j\) and \(x_{j+1}\), with fitted predictions \(\gamma_j\) and \(\gamma_{j+1}\), define \(t=(x-x_j)/(x_{j+1}-x_j)\). The piecewise-linear prediction is \(\theta_{\mathrm{spline}}(x)=(1-t)\gamma_j+t\gamma_{j+1}\). At \(x=x_j\), \(t=0\), so the prediction is \(\gamma_j\); at \(x=x_{j+1}\), \(t=1\), so it is \(\gamma_{j+1}\). This construction joins adjacent linear pieces continuously, although their slopes may differ at a knot.

Worked Example: Interpolating With the Spline

The spline predictions at 40 kg and 55 kg are 3.799905 and 4.379055 L/h before rounding. Find its prediction at 50 kg, which lies between those knots.

Here \(t=(50-40)/(55-40)=10/15=2/3\). Substituting in the interpolation formula gives:

$$ \theta_{\mathrm{spline}}(50) =\left(1-\frac{2}{3}\right)(3.799905) +\frac{2}{3}(4.379055) \approx4.186\ \text{L/h}. $$

The local slope on this interval is \((4.379055-3.799905)/15\approx0.03861\) L/h per kg. It differs from the 0.0450 L/h per kg additive slope, and the spline can have a different slope in the next interval. This prediction is interpolation within the observed range, not extrapolation.

Boundary Behavior, Diagnostics, and Alternatives

The predictions near the observed boundaries expose differences that can be obscured around the reference value. At 130 kg, the additive function predicts 7.700 L/h, while the exponential, power, and spline predictions are 7.167, 6.606, and 6.400 L/h. The additive function continues at the same absolute rate; the exponential function accelerates in absolute terms; the power function increases more gradually here; and the spline follows its final fitted segment.

Worked Example: What Happens Just Beyond the Data?

For illustration only, evaluate each function at 145 kg, 15 kg above the largest observed weight. These values are extrapolations: there are no observations at 145 kg to check them.

The additive prediction is \(5.00+0.0450(145-70)=8.375\) L/h. The exponential prediction is \(5.00\exp\{0.00600(75)\}=5.00\exp(0.450)\approx7.842\) L/h. The power prediction is \(5.00(145/70)^{0.450}\approx6.940\) L/h.

The spline uses the final segment from 115 to 130 kg, whose slope is \((6.400380-6.220035)/15\approx0.012023\) L/h per kg. Extending that line gives \(6.400380+0.012023(145-130)\approx6.581\) L/h. This extension is a consequence of the chosen linear-spline boundary rule, not evidence that clearance will follow that trend above 130 kg. The four predictions differ substantially despite being evaluated on the same data.

Useful diagnostics begin with plots of observed values and each fitted function against the covariate, using the same axes and units. Residuals—the observed values minus fitted predictions—can reveal systematic curvature, changing spread, or a few observations that dominate the apparent fit. A residual pattern does not by itself identify the correct function, but it can show that a candidate misses structure. In this example, the additive predictions rise far above several high-weight observations; that is a visible reason to inspect its upper-range fit rather than relying on its simple interpretation alone.

For the illustrative spline, the unrounded residuals at 40, 55, 70, 85, 100, 115, and 130 kg are approximately 0.000095, −0.079055, 0.035, −0.050045, 0.014955, −0.020035, and −0.000380 L/h. Their squared sum is approximately \(0.0106044\;(\text{L/h})^2\). A small residual sum of squares is not, by itself, enough to justify a flexible function: additional flexibility can follow noise, and predictions may be unstable where data are sparse.

The main alternatives have different trade-offs. An additive function is simple and directly interpretable in parameter units, but its absolute slope is constant. Exponential and power functions preserve positivity when their scale parameter is positive and encode proportional changes, but each imposes a particular global shape. A spline can accommodate changing slopes without requiring one global curve shape, but its behavior depends on knot placement and boundary specification, and flexible versions may require more information to estimate reliably. Compare candidates using scientific plausibility, fit over the observed range, parameter uncertainty, and a suitable model-selection or validation strategy—not a single row or prediction.

  • Check the scale and units. Confirm that the covariate is in the units used to define the coefficients and reference value. Changing kilograms to grams without changing the coefficient changes the model.
  • Inspect the edges. Look for sparse observations or systematic residual patterns near the minimum and maximum covariate values, where functions can separate most sharply.
  • Distinguish interpolation from extrapolation. A prediction between supported observations is not the same as a prediction outside their range; uncertainty and model dependence generally increase outside the data.
  • Do not interpret all coefficients alike. The additive coefficient is an absolute slope, the exponential coefficient is a log-scale rate per covariate unit, and the power exponent is an elasticity.

Common mistake: “The functions predict nearly the same value at 70 kg, so they are interchangeable.” They share a reference prediction, not a shape. At 130 kg, the additive and power predictions differ by more than 1 L/h, and beyond the observed range their implications diverge further. Compare predictions and interpretations across the covariate range that matters.

Key takeaway: Functional-form comparison is a comparison of assumptions as well as fit. Keep the dataset, parameter, units, and reference value fixed; examine predictions throughout the observed range; and treat boundary extrapolation as model-dependent rather than data-supported.

Check Your Understanding

Answer each question, then check the brief solutions.

  1. What does the coefficient 0.0450 mean in the additive function, including its units?
  2. Using the exponential function, what is the predicted ratio of clearance at 100 kg to clearance at 70 kg?
  3. Why is the 145 kg spline prediction less secure than the 50 kg spline prediction?
  4. Name one diagnostic that could reveal a systematic lack of fit near the upper observed boundary.

Solutions. (1) It is the constant increase in predicted clearance per kilogram: 0.0450 L/h per kg. (2) The ratio is \(\exp\{0.00600(100-70)\}=\exp(0.180)\approx1.1972\), so the prediction is about 19.7% higher at 100 kg. (3) The 50 kg value is interpolation between observed-range knots, whereas 145 kg is beyond the largest observed weight and depends on extending the last segment without supporting data. (4) Plot residuals against weight, or plot observed values and fitted curves together; a systematic residual trend near the upper weights would signal a possible lack of fit.