Update a model with events from a new rxode2 event table, while accounting for and interpolating any covariates or inter-occasion variability.
Usage
poso_replace_et(
target_model = NULL,
prior_model = NULL,
event_table = NULL,
interpolation = "locf"
)
Arguments
- target_model
Solved rxode2 object. A model generated by one of posologyr's estimation functions.
- prior_model
A
posologyr
prior population model.- event_table
An rxode2 event table.
- interpolation
Character string. Specifies the interpolation method to be used for covariates. Choices are "locf" for last observation carried forward, "nocb" for next observation carried backward, "midpoint", or "linear".
Examples
# model
mod_run001 <- function() {
ini({
THETA_Cl <- 4.0
THETA_Vc <- 70.0
THETA_Ka <- 1.0
ETA_Cl ~ 0.2
ETA_Vc ~ 0.2
ETA_Ka ~ 0.2
prop.sd <- sqrt(0.05)
})
model({
TVCl <- THETA_Cl
TVVc <- THETA_Vc
TVKa <- THETA_Ka
Cl <- TVCl*exp(ETA_Cl)
Vc <- TVVc*exp(ETA_Vc)
Ka <- TVKa*exp(ETA_Ka)
K20 <- Cl/Vc
Cc <- centr/Vc
d/dt(depot) = -Ka*depot
d/dt(centr) = Ka*depot - K20*centr
Cc ~ prop(prop.sd)
})
}
# df_patient01: event table for Patient01, following a 30 minutes intravenous
# infusion
df_patient01 <- data.frame(ID=1,
TIME=c(0.0,1.0,14.0),
DV=c(NA,25.0,5.5),
AMT=c(2000,0,0),
EVID=c(1,0,0),
DUR=c(0.5,NA,NA))
# estimate the prior distribution of population parameters
pop_model <- poso_simu_pop(dat=df_patient01,prior_model=mod_run001,n_simul=100)
#>
#>
#>
#>
# create a new rxode2 event table from the initial dataset
new_et <- rxode2::as.et(df_patient01)
new_et$add_sampling(seq(14,15,by=0.1))
# update the model with the new event table
poso_replace_et(pop_model$model,mod_run001,event_table=new_et)
#>
#>
#>
#>
#> ── Solved rxode2 object ──
#> ── Parameters ($params): ──
#> # A tibble: 100 × 8
#> sim.id THETA_Cl THETA_Vc THETA_Ka prop.sd ETA_Cl ETA_Vc ETA_Ka
#> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 4 70 1 0.224 -0.626 0.114 -1.09
#> 2 2 4 70 1 0.224 -0.00249 0.278 0.514
#> 3 3 4 70 1 0.224 -0.815 -0.111 -0.109
#> 4 4 4 70 1 0.224 -0.126 -0.248 0.281
#> 5 5 4 70 1 0.224 0.924 -0.729 0.229
#> 6 6 4 70 1 0.224 -0.833 -0.233 -0.0235
#> 7 7 4 70 1 0.224 0.243 -0.409 0.209
#> 8 8 4 70 1 0.224 0.162 -0.583 0.330
#> 9 9 4 70 1 0.224 0.845 -0.0436 -0.419
#> 10 10 4 70 1 0.224 -0.00713 -0.370 -0.676
#> # ℹ 90 more rows
#> ── Initial Conditions ($inits): ──
#> depot centr AUC
#> 0 0 0
#>
#> Simulation without uncertainty in parameters, omega, or sigma matricies
#>
#> ── First part of data (object): ──
#> # A tibble: 1,300 × 14
#> sim.id time TVCl TVVc TVKa Cl Vc Ka K20 rxCc Cc depot
#> <int> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
#> 1 1 1 4 70 1 2.14 78.5 0.336 0.0273 5.60 5.60 1556.
#> 2 1 14 4 70 1 2.14 78.5 0.336 0.0273 18.8 18.8 19.7
#> 3 1 14 4 70 1 2.14 78.5 0.336 0.0273 18.8 18.8 19.7
#> 4 1 14.1 4 70 1 2.14 78.5 0.336 0.0273 18.8 18.8 19.0
#> 5 1 14.2 4 70 1 2.14 78.5 0.336 0.0273 18.7 18.7 18.4
#> 6 1 14.3 4 70 1 2.14 78.5 0.336 0.0273 18.7 18.7 17.8
#> # ℹ 1,294 more rows
#> # ℹ 2 more variables: centr <dbl>, AUC <dbl>