add_covariate_effect {pharmr} | R Documentation |
add_covariate_effect
Description
Adds covariate effect to :class:pharmpy.model
.
The following effects have templates:
Linear function for continuous covariates (lin)
Function:
math::
coveff = 1 + theta * (cov - median)
Init: 0.001
Upper:
If median of covariate equals minimum: :math:
100,000
Otherwise: :math:
frac{1}{{median} - {min}}
Lower:
If median of covariate equals maximum: :math:
-100,000
Otherwise: :math:
frac{1}{{median} - {max}}
Linear function for categorical covariates (cat)
Function:
If covariate is most common category:
math::
coveff = 1
For each additional category:
math::
coveff = 1 + theta
Init: :math:
0.001
Upper: :math:
100,000
Lower: :math:
-100,000
Piecewise linear function/"hockey-stick", continuous covariates only (piece_lin)
Function:
If cov <= median:
math::
coveff = 1 + theta1 * (cov - median)
If cov > median:
math::
coveff = 1 + theta2 * (cov - median)
Init: :math:
0.001
Upper:
For first state: :math:
frac{1}{{median} - {min}}
Otherwise: :math:
100,000
Lower:
For first state: :math:
-100,000
Otherwise: :math:
frac{1}{{median} - {max}}
Exponential function, continuous covariates only (exp)
Function:
math::
coveff = exp(theta * (cov - median))
Init:
If lower > 0.001 or upper < 0.001: :math:
frac{{upper} - {lower}}{2}
If estimated init is 0: :math:
frac{{upper}}{2}
Otherwise: :math:
0.001
Upper:
If min - median = 0 or max - median = 0: :math:
100
Otherwise:
math::
min(fraclog(0.01)min - median, fraclog(100)max - median)
Lower:
If min - median = 0 or max - median = 0: :math:
0.01
Otherwise:
math::
max(fraclog(0.01)max - median, fraclog(100)min - median)
Power function, continuous covariates only (pow)
Function:
math::
coveff = (fraccovmedian)^theta
Init: :math:
0.001
Upper: :math:
100,000
Lower: :math:
-100
Usage
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. |
Value
(Model) Pharmpy model object
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)