Example: Covariate model

A two-compartment oral model with body weight (WT) and creatinine clearance (CRCL) as covariates on clearance.

Tip

For background on covariate parameterisation, see Chapter 3 (Model DSL) in the ferx book.

Model file

# Two-compartment oral PK model with covariates

[parameters]
  theta TVCL(5.0, 0.01, 100.0)
  theta TVV1(50.0, 0.1, 1000.0)
  theta TVQ(10.0, 0.01, 200.0)
  theta TVV2(100.0, 0.1, 5000.0)
  theta TVKA(1.0, 0.01, 50.0)
  theta THETA_WT(0.75, 0.01, 2.0)
  theta THETA_CRCL(0.5, 0.01, 2.0)

  omega ETA_CL ~ 0.09
  omega ETA_V1 ~ 0.04
  omega ETA_Q  ~ 0.04
  omega ETA_V2 ~ 0.09
  omega ETA_KA ~ 0.25

  sigma PROP_ERR ~ 0.04

[individual_parameters]
  CL = TVCL * exp(ETA_CL) * (WT/70)^THETA_WT * (CRCL/100)^THETA_CRCL
  V1 = TVV1 * exp(ETA_V1)
  Q  = TVQ  * exp(ETA_Q)
  V2 = TVV2 * exp(ETA_V2)
  KA = TVKA * exp(ETA_KA)

[structural_model]
  pk two_cpt_oral(cl=CL, v1=V1, q=Q, v2=V2, ka=KA)

[error_model]
  DV ~ proportional(PROP_ERR)

[fit_options]
  method     = focei
  maxiter    = 500
  covariance = true

Covariate effects

The clearance equation includes two covariate effects:

CL = TVCL * exp(ETA_CL) * (WT/70)^THETA_WT * (CRCL/100)^THETA_CRCL
  • (WT/70)^THETA_WT — allometric scaling with body weight, centred at 70 kg. THETA_WT is estimated (typical value ~0.75 for CL).
  • (CRCL/100)^THETA_CRCL — renal function effect, centred at 100 mL/min. THETA_CRCL is estimated.

Both effects are centred: when WT = 70 kg and CRCL = 100 mL/min, both terms equal 1.0, so TVCL is interpretable as the clearance of a 70 kg patient with normal renal function.

TipMu-referencing with covariates

Both term orderings are detected correctly — ferx recognises the theta * exp(eta) mu-reference regardless of where covariate multipliers appear:

CL = TVCL * exp(ETA_CL) * (WT/70)^0.75   # fine
CL = TVCL * (WT/70)^0.75 * exp(ETA_CL)   # also fine

Data requirements

The dataset must include WT and CRCL columns:

ID,TIME,DV,EVID,AMT,CMT,MDV,WT,CRCL
1,0,.,1,100,1,1,72.5,105
1,0.5,12.3,0,.,.,0,72.5,105
1,1.0,18.7,0,.,.,0,72.5,105

Covariate columns are automatically detected — any column not in the standard NONMEM set (ID, TIME, DV, EVID, AMT, CMT, RATE, MDV, CENS, II, SS) is treated as a covariate. Names in the data file are matched case-insensitively against those used in [individual_parameters].

In R

library(ferx)
ex  <- ferx_example("two_cpt_oral_cov")
fit <- ferx_fit(ex$model, ex$data)
print(fit)

# ETA-covariate correlations: check if covariates were absorbed
data <- read.csv(ex$data)
ferx_eta_cov(fit, data)
# ETA_CL correlations with WT and CRCL should be near zero after fitting

Notes

  • FOCEI is used here because the proportional error model creates an interaction between random effects and residual error.
  • The estimated covariate exponents (THETA_WT, THETA_CRCL) have standard errors that can be used for a likelihood-ratio test of significance.
  • The initial values for covariate thetas (THETA_WT = 0.75, THETA_CRCL = 0.5) are the allometric theory values — informative starting points that speed convergence.