add_covariate_effect function

add_covariate_effect

add_covariate_effect

Adds covariate effect to :class:pharmpy.model.

The following effects have templates:

  • Linear function for continuous covariates (lin)
  • Function:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper:
  • If median of covariate equals minimum: 100,000
  • Otherwise: (equation could not be rendered, see API doc on website)
  • Lower:
  • If median of covariate equals maximum: -100,000
  • Otherwise: (equation could not be rendered, see API doc on website)
  • Linear function for categorical covariates (cat)
  • Function:
  • If covariate is the most common category:

(equation could not be rendered, see API doc on website)

  • For each additional category:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper: 5
  • Lower: -1
  • (alternative) Linear function for categorical covariates (cat2)
  • Function:
  • If covariate is the most common category:

(equation could not be rendered, see API doc on website)

  • For each additional category:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper: 6
  • Lower: 0
  • Piecewise linear function/"hockey-stick", continuous covariates only (piece_lin)
  • Function:
  • If cov <= median:

(equation could not be rendered, see API doc on website)

  • If cov > median:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper:
  • For first state: (equation could not be rendered, see API doc on website)
  • Otherwise: 100,000
  • Lower:
  • For first state: -100,000
  • Otherwise: (equation could not be rendered, see API doc on website)
  • Exponential function, continuous covariates only (exp)
  • Function:

(equation could not be rendered, see API doc on website)

  • Init:
  • If lower > 0.001 or upper < 0.001: (equation could not be rendered, see API doc on website)
  • If estimated init is 0: (equation could not be rendered, see API doc on website)
  • Otherwise: 0.001
  • Upper:
  • If min - median = 0 or max - median = 0: 100
  • Otherwise:

(equation could not be rendered, see API doc on website)

  • Lower:
  • If min - median = 0 or max - median = 0: 0.01
  • Otherwise:

(equation could not be rendered, see API doc on website)

  • Power function, continuous covariates only (pow)
  • Function:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper: 100,000
  • Lower: -100
add_covariate_effect( model, parameter, covariate, effect, operation = "*", allow_nested = FALSE )

Arguments

  • model: (Model) Pharmpy model to add covariate effect to.
  • parameter: (str) Name of parameter to add covariate effect to.
  • covariate: (str) Name of covariate.
  • effect: (str) Type of covariate effect. May be abbreviated covariate effect (see above) or custom.
  • operation: (str) Whether the covariate effect should be added or multiplied (default).
  • allow_nested: (logical) Whether to allow adding a covariate effect when one already exists for the input parameter-covariate pair.

Returns

(Model) Pharmpy model object

Description

Adds covariate effect to :class:pharmpy.model.

The following effects have templates:

  • Linear function for continuous covariates (lin)
  • Function:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper:
  • If median of covariate equals minimum: 100,000
  • Otherwise: (equation could not be rendered, see API doc on website)
  • Lower:
  • If median of covariate equals maximum: -100,000
  • Otherwise: (equation could not be rendered, see API doc on website)
  • Linear function for categorical covariates (cat)
  • Function:
  • If covariate is the most common category:

(equation could not be rendered, see API doc on website)

  • For each additional category:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper: 5
  • Lower: -1
  • (alternative) Linear function for categorical covariates (cat2)
  • Function:
  • If covariate is the most common category:

(equation could not be rendered, see API doc on website)

  • For each additional category:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper: 6
  • Lower: 0
  • Piecewise linear function/"hockey-stick", continuous covariates only (piece_lin)
  • Function:
  • If cov <= median:

(equation could not be rendered, see API doc on website)

  • If cov > median:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper:
  • For first state: (equation could not be rendered, see API doc on website)
  • Otherwise: 100,000
  • Lower:
  • For first state: -100,000
  • Otherwise: (equation could not be rendered, see API doc on website)
  • Exponential function, continuous covariates only (exp)
  • Function:

(equation could not be rendered, see API doc on website)

  • Init:
  • If lower > 0.001 or upper < 0.001: (equation could not be rendered, see API doc on website)
  • If estimated init is 0: (equation could not be rendered, see API doc on website)
  • Otherwise: 0.001
  • Upper:
  • If min - median = 0 or max - median = 0: 100
  • Otherwise:

(equation could not be rendered, see API doc on website)

  • Lower:
  • If min - median = 0 or max - median = 0: 0.01
  • Otherwise:

(equation could not be rendered, see API doc on website)

  • Power function, continuous covariates only (pow)
  • Function:

(equation could not be rendered, see API doc on website)

  • Init: 0.001
  • Upper: 100,000
  • Lower: -100

Examples

## Not run: model <- load_example_model("pheno") model <- add_covariate_effect(model, "CL", "APGR", "exp") model$statements$before_odes$full_expression("CL") ## End(Not run)
  • Maintainer: Rikard Nordgren
  • License: LGPL (>= 3)
  • Last published: 2024-12-04