run_Build_PK_Oral {EHR} | R Documentation |
Build-PK-Oral Module
Description
This module builds PK data for orally administered medications.
Usage
run_Build_PK_Oral(
x,
idCol = "id",
dtCol = "dt",
doseCol = "dose",
concCol = "conc",
ldCol = NULL,
first_interval_hours = 336,
imputeClosest = NULL
)
Arguments
x |
a data.frame or file saved as either CSV, RData, or RDS |
idCol |
data.frame id column name |
dtCol |
data.frame date column name |
doseCol |
dose column name |
concCol |
concentration column name |
ldCol |
last-dose time column name |
first_interval_hours |
number of hours before the first concentration to start time=0; the default is 336 hours = 14 days |
imputeClosest |
columns to impute missing data with next observation propagated backward; this is in addition to all covariates receving imputation using last observation carried forward |
Details
See EHR Vignette for Build-PK-Oral.
Value
data.frame
Examples
## Data Generating Function
mkdat <- function() {
npat <- 3
visits <- floor(runif(npat, min=2, max=6))
id <- rep(1:npat, visits)
dt_samp <- as.Date(sort(sample(700, sum(visits))), origin = '2019-01-01')
tm_samp <- as.POSIXct(paste(dt_samp, '10:00:00'), tz = 'UTC')
dt <- tm_samp + rnorm(sum(visits), 0, 1*60*60)
dose_morn <- sample(c(2.5,5,7.5,10), sum(visits), replace = TRUE)
conc <- round(rnorm(sum(visits), 1.5*dose_morn, 1),1)
ld <- dt - sample(10:16, sum(visits), replace = TRUE) * 3600
ld[rnorm(sum(visits)) < .3] <- NA
age <- rep(sample(40:75, npat), visits)
gender <- rep(sample(0:1, npat, replace=TRUE), visits)
weight <- rep(round(rnorm(npat, 180, 20)),visits)
hgb <- rep(rnorm(npat, 10, 2), visits)
data.frame(id, dt, dose_morn, conc, ld, age, gender, weight, hgb)
}
# Make raw data
set.seed(30)
dat <- mkdat()
#Process data without last-dose times
run_Build_PK_Oral(x = dat,
idCol = "id",
dtCol = "dt",
doseCol = "dose_morn",
concCol = "conc",
ldCol = NULL,
first_interval_hours = 336,
imputeClosest = NULL)
#Process data with last-dose times
run_Build_PK_Oral(x = dat, doseCol = "dose_morn", ldCol = "ld")
[Package EHR version 0.4-11 Index]