Learn R Programming

nlmixr2auto (version 1.0.0)

add_covariate: Add a covariate effect to a parameter model

Description

Automates the creation of covariate effects in pharmacometric models by generating appropriate beta coefficients and modifying model expressions. Supports both standard allometric scaling rules and custom covariate effects.

Usage

add_covariate(
  param_name,
  covariate_var,
  param_model,
  beta_value = NULL,
  existing_betas = c(),
  use_fix = TRUE
)

Value

List with two elements:

  • betas - Updated character vector of beta definitions

  • mod - Modified model expression with covariate term

Arguments

param_name

Character. Target parameter name (e.g., "cl", "vc").

covariate_var

Character. Covariate variable name (e.g., "WT", "BMI").

param_model

Character. Current parameter model expression (e.g., "cl = exp(tcl)").

beta_value

Numeric. Optional fixed beta value. If NULL, uses built-in rules.

existing_betas

Character vector. Existing beta definitions to append to.

use_fix

Logical. Use fix() for beta values? Default TRUE.

Author

Zhonghui Huang

Details

Automatic beta selection rules:

  • Standard covariates ("wt"/"ffm"/"bmi"/"bsa"):

    • 0.75 for clearance parameters (cl/q/q2)

    • 1.0 for volume parameters (vc/vp/vp2)

  • Other covariates: Default beta = -0.1 with message

Examples

Run this code
# Add weight effect to clearance
 add_covariate( "cl", "WT", "cl = exp(tcl)")

# Custom beta value for BMI effect
add_covariate(
  "vc", "BMI", "vc = exp(tvc)",
  beta_value = -0.2, use_fix = FALSE
)

Run the code above in your browser using DataLab