Append a model to another"

EXPORT_PNG <- FALSE

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.

Prerequisite

The examples below require the package campismod.

library(campsismod)

Load your base PK model

The following code will load our reference 2-compartment PK model.

pk_model <- model_suite$pk$`2cpt_fo`

Load an effect-compartment model

The effect-compartment model can be loaded from the model library as follows:

pd_model <- model_suite$pd$effect_cmt_model
pd_model

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 <- pd_model %>% replace(Equation("PK_CONC", "A_CENTRAL/VC"))

Append PD model to PK model

Appending the PD model to the PK model is done using the add function:

pkpd_model <- pk_model %>% add(pd_model)
pkpd_model

Simulate our PK/PD model

Let's now simulate our PK/PD model:

library(campsis)
dataset <- Dataset(25) %>% 
  add(Bolus(time=0, amount=1000, compartment=1, ii=12, addl=2)) %>%
  add(Observations(times=0:36))
results <- pkpd_model %>% simulate(dataset=dataset, seed=1)
shadedPlot(results, "CONC")
shadedPlot(results, "CONC")
ggplot2::ggsave(filename="resources/pkpd_model_concentration.png", width=7, height=3, dpi=100)

PK concentration

shadedPlot(results, "EFFECT")
ggplot2::ggsave(filename="resources/pkpd_model_effect.png", width=7, height=3, dpi=100)

Showing the delayed effect



Try the campsismod package in your browser

Any scripts or data that you put into this service are public.

campsismod documentation built on Oct. 12, 2023, 5:13 p.m.