Create a list of PKPDsim covariates for modeling
create_cov_object.Rd
Data sets typically come in rectangular formats while for MIPD trials we model each individual separately. PKPDsim expects covariates to be provided as a list of PKPDsim covariates. This function helps convert rectangular (wide) data to model-ready covariates.
Arguments
- dat_i
a rectangular data set, containing only rows for an individual
- mapping
named vector indicating which columns to extract, and what the covariate names are expected in the model. Names should be model covariates and values should be data frame column names.
- implementation
named vector indicating covariate implementation, one of
c("interpolate", "locf")
. If NULL, assumes "interpolate" for all covariates. SeePKPDsim::new_covariate
for details. Names should be model covariates and values should be implementation method.- time_column
if covariates are time-varying, supply a column for time. Otherwise, initial value only is taken for all covariates.
Details
The data is assumed to already be numeric (e.g., categorical covariates like smoking status have already been mapped to 1 or 0).
The function returns NULL if required columns are missing or NA.
Examples
dat <- data.frame(ID = 1, weight = 70, CRCL = 4)
mapping <- c(WT = "weight", CRCL = "CRCL")
create_cov_object(dat, mapping)
#> $WT
#> value times unit implementation
#> 1 70 0 undefined interpolate
#>
#> $CRCL
#> value times unit implementation
#> 1 4 0 undefined interpolate
#>