Covariates are implemented using the
function, wrapped in a named list. For example:
<- list( covariates "WT" = new_covariate(value = 70), "SCR" = new_covariate(value = 120) )
The names in the covariate list-object should correspond exactly with the names of the covariates in the model.
Time-varing covariates, such as creatinine values can be implemented
easily as well. They just require the additional
<- list( covariates "WT" = new_covariate(value = 70), "CR" = new_covariate( value = c(0.8, 1, 1.2), times = c(0, 48, 72) ))
PKPDsim assumes that you want to interpolate
(linearly) between measurements of the time-varying covariates. If you
prefer to implement the covariate using
last-observation-carried-forward (in other words a step
function), specify the
method = "LOCF" argument to
A table of covariates can be supplied to
covariate values per individual. It can handle both static and
time-varying covariates. A covariate table could look like this:
<- data.frame( cov_table id = c(1, 1, 2, 3), WT = c(40, 45, 50, 60), SCR = c(50, 150, 90, 110), t = c(0, 5, 0, 0) )
t (time) columns can be omitted
when only static covariates are to be used. Again, make sure that the
headers used for the covariates match exactly with the
covariate names specified in the model definition.
A full example for a model with (simulated) covariates for a patient population:
<- list( parameters CL = 1, V = 10, KA = 0.5 )<- 50 n_ind <- data.frame( cov_table 'id' = 1:n_ind, 'WT' = rnorm(n_ind, mean = 70, sd = 5) ) <- new_ode_model( model code = ' CLi = CL * pow((WT/70), 0.75) Vi = V * (WT/70) dAdt = -KA*A dAdt = KA*A -(CLi/Vi)*A ', declare_variables = c('CLi', 'Vi'), covariates = c('WT'), dose = list(cmt = 1), obs = list(cmt = 2, scale = 'V * (WT/70)') ) <- new_regimen( regimen amt = 30, n = 4, type = 'bolus', interval = 12 ) <- sim( dat ode = model, parameters = parameters, t_obs = c(0.5, 2, 4, 8, 12, 16, 24), n_ind = n_ind, regimen = regimen, covariates_table = cov_table, output_include = list(covariates = TRUE) )
## Simulating 50 individuals.
Note: PKPDsim does not handle missing covariate values. If you do have missing covariate data, probably the best approach would be to impute the values manually before simulation, e.g. based on the mean observed / known value, or the correlation between the covariates.