Building the First Covariate Model

Learn standard covariate model structures and implement a simple covariate model in nlmixr2.
Tip

Big picture: Covariates explain systematic differences between subjects and reduce unexplained variability.

Learning Objectives

By the end of this lesson, you will be able to:

  • distinguish continuous and categorical covariate models
  • explain common covariate parameterizations
  • explain normalization
  • implement a covariate model in nlmixr2
  • interpret covariate effects

Key Ideas

  • covariates modify parameters
  • model structure matters
  • normalization improves interpretation
  • ETA usually remains

Setup

library(tidyverse)
library(nlmixr2)
library(nlmixr2data)

data("theo_sd", package = "nlmixr2data")

Inspect variables.

names(theo_sd)
[1] "ID"   "TIME" "DV"   "AMT"  "EVID" "CMT"  "WT"  

Notice:

WT already exists in the dataset.

Why Add Covariates?

Without covariates:

\[ CL_i=Typical\ CL+\eta_i \]

With covariates:

\[ CL_i= Typical\ CL+ Covariate\ Effect+ \eta_i \]

Covariates explain variability.

They usually do not eliminate variability.


Worked Example 1: Continuous Covariate Models

Continuous covariates include:

WT, AGE

Linear Additive

\[ TVCL=\theta_1+\theta_2WT_i \]

\[ CL_i=TVCL\exp(\eta_i) \]

Interpretation:

  • \(\theta_1\) → baseline clearance
  • \(\theta_2\) → change per covariate unit

When to use:

  • Useful when the covariate effect is approximately linear over the observed range.
  • Often reasonable for narrow covariate ranges.
  • Can produce unrealistic predictions when extrapolated far beyond the data.

Linear Centered

\[ TVCL= \theta_1+ \theta_2(WT_i-WT_{ref}) \]

\[ CL_i= TVCL\exp(\eta_i) \]

Interpretation:

  • \(\theta_1\) → clearance at \(WT_{ref}\)

Example:

  • \(WT_{ref}=70\)

When to use:

  • Same functional form as the linear additive model.
  • Preferred when a meaningful reference value exists.
  • Makes parameter interpretation easier because θ₁ represents the typical value at the reference covariate.

Power Model

\[ TVCL= \theta_1WT_i^{\theta_2} \]

\[ CL_i= TVCL\exp(\eta_i) \]

Interpretation:

  • \(\theta_2\) controls scaling

When to use:

  • Common when biological relationships are proportional rather than additive.
  • Often provides more realistic behavior across wide covariate ranges.
  • Frequently used for body size effects.

Power Model with Normalized Covariate

\[ TVCL= \theta_1 \left( \frac{WT_i}{WT_{ref}} \right)^{\theta_2} \]

\[ CL_i= TVCL\exp(\eta_i) \]

Interpretation:

  • \(WT=70\) → no adjustment
  • \(WT>70\) → higher or lower \(TVCL\) depending on \(\theta_2\)
  • \(WT<70\) → lower or higher \(TVCL\) depending on \(\theta_2\)

When to use:

  • Widely used in population PK models.
  • The reference value gives θ₁ a clear interpretation as the typical parameter value at the reference covariate.
  • Supports comparison across studies and populations.

Log-Transformed Power Model

\[ LNCL= \theta_1+ \theta_2 \log \left( \frac{WT_i}{WT_{ref}} \right)+ \eta_i \]

\[ CL_i=\exp(LNCL) \]

Interpretation:

Equivalent formulation on the log scale.

When to use:

  • Convenient for estimation because multiplicative relationships become linear on the log scale.
  • Commonly encountered in statistical descriptions of covariate models.
  • Often mathematically equivalent to the normalized power model.

Comparing Continuous Covariate Models

Model Main Advantage Typical Use
Linear Additive Simple Narrow covariate ranges
Linear Centered Easy interpretation General covariate modeling
Power Flexible scaling Body size relationships
Normalized Power Interpretable and scalable Most common PK covariate model
Log-Transformed Power Convenient estimation Statistical formulations

Worked Example 2: Categorical Covariate Models

Categorical covariates include:

SEX, FORMULATION, DISEASE GROUP

Assume:

  • \(SEX=0\) → Female
  • \(SEX=1\) → Male

Linear Additive

\[ TVCL= \theta_1+ \theta_2SEX_i \]

\[ CL_i= TVCL\exp(\eta_i) \]

Interpretation:

  • \(\theta_2\) produces an absolute shift

When to use:

  • Appropriate when the covariate effect is expected to add or subtract a fixed amount.
  • Easy to interpret.
  • Less common for PK parameters because many biological effects are proportional rather than additive.

Linear Proportional

\[ TVCL= \theta_1 (1+\theta_2SEX_i) \]

\[ CL_i= TVCL\exp(\eta_i) \]

Interpretation:

  • \(\theta_2=0.2\) → 20% higher \(TVCL\)

When to use:

  • Common for PK and PD parameters.
  • Represents the effect as a percentage change from the reference group.
  • Often easier to interpret biologically than an absolute shift.

Power Model

\[ TVCL= \theta_1 \theta_2^{SEX_i} \]

\[ CL_i= TVCL\exp(\eta_i) \]

Interpretation:

  • \(SEX=0\)\(TVCL=\theta_1\)
  • \(SEX=1\)\(TVCL=\theta_1\theta_2\)

When to use:

  • Common for binary covariates.
  • Directly estimates the ratio between groups.
  • Frequently used when multiplicative effects are expected.

Log-Transformed Power Model

\[ LNCL= \theta_1+ SEX_i \log(\theta_2)+ \eta_i \]

\[ CL_i= \exp(LNCL) \]

Interpretation:

Equivalent formulation on the log scale.

When to use:

  • Convenient for estimation and statistical interpretation.
  • Common in theoretical descriptions of multiplicative covariate effects.
  • Often mathematically equivalent to the power model.

For binary covariates, proportional and power models are often preferred because they naturally describe relative differences between groups, which are common in pharmacometric applications.

Comparing Categorical Covariate Models

Model Interpretation of Effect Typical Use
Linear Additive Fixed change Less common for PK parameters
Linear Proportional Percent change Common PK/PD applications
Power Group ratio Common binary covariates
Log-Transformed Power Log-scale ratio Statistical formulations

Worked Example 3: Start With the Base Model

base_model <- function(){

    ini({

        tka <- log(1)
        tcl <- log(3)
        tv <- log(30)

        eta.ka ~ 0.1
        eta.cl ~ 0.1
        eta.v ~ 0.1

        add.err <- 0.1

    })

    model({

        ka <- exp(tka + eta.ka)
        cl <- exp(tcl + eta.cl)
        v <- exp(tv + eta.v)

        linCmt() ~ add(add.err)

    })

}

This implies:

\[ CL_i= \exp( tcl+\eta_{CL} ) \]

Only random effects drive differences.


Worked Example 4: Add Weight to Clearance

Use a normalized power model.

cov_model <- function(){

    ini({

        tka <- log(1)

        tcl <- log(3)
        wt.cl <- 0.75

        tv <- log(30)

        eta.ka ~ 0.1
        eta.cl ~ 0.1
        eta.v ~ 0.1

        add.err <- 0.1

    })

    model({

        ka <- exp(tka + eta.ka)

        cl <- exp(tcl + wt.cl * log(WT / 70) + eta.cl)

        v <- exp(tv + eta.v)

        linCmt() ~ add(add.err)

    })

}

Equivalent equation:

\[ CL_i= \exp \left( tcl+ wt.cl \log \left( \frac{WT_i}{70} \right)+ \eta_{CL} \right) \]

Interpretation:

  • \(WT=70\) → reference
  • larger deviations → stronger adjustment

Worked Example 5: Estimate the Covariate Model

fit_cov <-
  nlmixr2(
    cov_model,
    theo_sd,
    est = "focei",
    control = list(print = 0)
  )

Inspect:

coef(fit_cov)$fixed
      tka       tcl     wt.cl        tv   add.err 
0.4636809 1.0238602 0.5332719 3.4607593 0.6949543 

Look for:

\[ wt.cl \]

Interpretation:

\(wt.cl\) controls the strength of the weight effect.


Why Normalize?

Using:

\[ \frac{WT}{70} \]

means:

compare each subject to a reference subject

At:

\[ WT=70 \]

the covariate contribution becomes:

\[ \log(1)=0 \]


Compare Before and After

Before:

\[ CL_i= Typical\ CL+ \eta_i \]

After:

\[ CL_i= Typical\ CL+ Weight\ Effect+ \eta_i \]

Goal:

large ETA → smaller remaining ETA

Covariates Do Not Replace Biology

Ask:

  • biologically plausible?
  • interpretable?
  • clinically meaningful?

Do not add covariates automatically.


Looking Ahead

Next we ask:

How do we interpret the size and meaning of covariate effects?


Strategies

  • normalize continuous covariates
  • keep categorical coding explicit
  • keep biology first

Common Mistakes

  • adding every variable
  • confusing significance with usefulness
  • ignoring reference values

Practice Problems

  1. Why normalize continuous covariates?

  2. Interpret:

\[ WT/70 \]

  1. Compare continuous and categorical covariates.

  2. What does wt.cl represent?

  3. Why keep ETA?


Problem 1

Normalization improves interpretation.


Problem 2

Each subject is compared to a 70 kg reference.


Problem 3

Continuous covariates vary numerically.

Categorical covariates represent groups.


Problem 4

wt.cl controls the covariate strength.


Problem 5

Covariates usually explain only part of variability.


Summary

  • covariates modify parameters
  • normalized power models are common
  • categorical covariates use indicator structures
  • ETA usually remains

  • Normalize
  • Keep ETA
  • Biology first