This vignette shows how a model can be appended to another. This is particularly useful when appending a PD model to a existing PK model. In this vignette, we’ll demonstrate how an effect compartment model can be appended to a 2-compartment model.
The examples below require the package campismod
.
library(campsismod)
The following code will load our reference 2-compartment PK model.
<- model_library$advan4_trans4 pk_model
The effect-compartment model can be loaded from the model library as follows:
<- model_library$effect_cmt_model
pd_model pd_model
## [MAIN]
## KE0=THETA_KE0*exp(ETA_KE0)
##
## [ODE]
## PK_CONC=10
## d/dt(A_EFFECT)=KE0*(PK_CONC - A_EFFECT)
##
##
## THETA's:
## name index value fix
## 1 KE0 1 0.25 FALSE
## OMEGA's:
## name index index2 value fix type same
## 1 KE0 1 1 15 FALSE cv% NA
## SIGMA's:
## # A tibble: 0 × 0
## No variance-covariance matrix
##
## Compartments:
## A_EFFECT (CMT=1)
This PD model has a variable PK_CONC
, that needs to be
linked with the PK concentration.
Therefore, we need to adapt it as follows:
<- pd_model %>% replace(Equation("PK_CONC", "A_CENTRAL/S2")) pd_model
Appending the PD model to the PK model is done using the
add
function:
<- pk_model %>% add(pd_model)
pkpd_model pkpd_model
## [MAIN]
## KA=THETA_KA*exp(ETA_KA)
## CL=THETA_CL*exp(ETA_CL)
## V2=THETA_V2*exp(ETA_V2)
## V3=THETA_V3*exp(ETA_V3)
## Q=THETA_Q*exp(ETA_Q)
## S2=V2
## KE0=THETA_KE0*exp(ETA_KE0)
##
## [ODE]
## d/dt(A_DEPOT)=-KA*A_DEPOT
## d/dt(A_CENTRAL)=KA*A_DEPOT + Q*A_PERIPHERAL/V3 + (-CL/V2 - Q/V2)*A_CENTRAL
## d/dt(A_PERIPHERAL)=-Q*A_PERIPHERAL/V3 + Q*A_CENTRAL/V2
## d/dt(A_OUTPUT)=CL*A_CENTRAL/V2
## F=A_CENTRAL/S2
## PK_CONC=A_CENTRAL/S2
## d/dt(A_EFFECT)=KE0*(PK_CONC - A_EFFECT)
##
## [ERROR]
## CP=F
## OBS_CP=CP*(EPS_PROP + 1)
## Y=OBS_CP
##
##
## THETA's:
## name index value fix
## 1 KA 1 1.00 FALSE
## 2 CL 2 5.00 FALSE
## 3 V2 3 80.00 FALSE
## 4 V3 4 20.00 FALSE
## 5 Q 5 4.00 FALSE
## 6 KE0 6 0.25 FALSE
## OMEGA's:
## name index index2 value fix type same
## 1 KA 1 1 0.025 FALSE var NA
## 2 CL 2 2 0.025 FALSE var NA
## 3 V2 3 3 0.025 FALSE var NA
## 4 V3 4 4 0.025 FALSE var NA
## 5 Q 5 5 0.025 FALSE var NA
## 6 KE0 6 6 15.000 FALSE cv% NA
## SIGMA's:
## name index index2 value fix type
## 1 PROP 1 1 0.025 FALSE var
## No variance-covariance matrix
##
## Compartments:
## A_DEPOT (CMT=1)
## A_CENTRAL (CMT=2)
## A_PERIPHERAL (CMT=3)
## A_OUTPUT (CMT=4)
## A_EFFECT (CMT=5)
Let’s now simulate our PK/PD model:
library(campsis)
<- Dataset(25) %>%
dataset add(Bolus(time=0, amount=1000, compartment=1, ii=12, addl=2)) %>%
add(Observations(times=0:36))
<- pkpd_model %>% simulate(dataset=dataset, seed=1)
results shadedPlot(results, "CP")
shadedPlot(results, "CP")
PK concentration
shadedPlot(results, "A_EFFECT")
Showing the delayed effect