For this vignette, please load the campsismod
package
and load the minimalist model that we have created in the first
vignette.
Let’s invent a very basic scenario: we would like to infuse
1000
into the central compartment with a fixed rate of
100
and a fixed lag time of 2
.
First, we’re going to delete the initial condition that we had in the
minimalist model. This is done as follows:
## [MAIN]
## K=THETA_K*exp(ETA_K) # Elimination constant
##
## [ODE]
## d/dt(A_CENTRAL)=-K*A_CENTRAL
##
##
## THETA's:
## name index value fix
## 1 K 1 0.06 FALSE
## OMEGA's:
## name index index2 value fix type
## 1 K 1 1 15 FALSE cv%
## SIGMA's:
## # A tibble: 0 × 0
## No variance-covariance matrix
##
## Compartments:
## A_CENTRAL (CMT=1)
This is strictly equal as doing (if you prefer working with compartment names):
We can now add a fixed rate for all infusions that go into the central compartment:
Finally, let’s now add a constant lag time:
OK, this is how our model looks like now:
## [MAIN]
## K=THETA_K*exp(ETA_K) # Elimination constant
##
## [ODE]
## d/dt(A_CENTRAL)=-K*A_CENTRAL
##
## [LAG]
## A_CENTRAL=2
##
## [RATE]
## A_CENTRAL=100
##
##
## THETA's:
## name index value fix
## 1 K 1 0.06 FALSE
## OMEGA's:
## name index index2 value fix type
## 1 K 1 1 15 FALSE cv%
## SIGMA's:
## # A tibble: 0 × 0
## No variance-covariance matrix
##
## Compartments:
## A_CENTRAL (CMT=1)
Let’s now simulate a few individuals and show A_CENTRAL
,
i.e., the amount of drug in the central compartment.
First, we need to define an infusion of 1000
in a
CAMPSIS dataset, as well as the observations times.
library(campsis)
dataset <- Dataset(5) %>%
add(Infusion(time=0, amount=1000)) %>%
add(Observations(seq(0,36,by=0.5)))
Then, we can run the simulation.
As previously, let’s demonstrate the use of a couple of interesting functions:
Check the existence of a compartment:
## [1] TRUE
## [1] TRUE
Check the existence of a property:
## [1] TRUE
## [1] FALSE
Find a compartment:
## A_CENTRAL (CMT=1)
Find a compartment property:
## RATE (CMT=1): 100
Replace a compartment property:
## [MAIN]
## K=THETA_K*exp(ETA_K) # Elimination constant
##
## [ODE]
## d/dt(A_CENTRAL)=-K*A_CENTRAL
##
## [LAG]
## A_CENTRAL=2
##
## [RATE]
## A_CENTRAL=200
##
##
## THETA's:
## name index value fix
## 1 K 1 0.06 FALSE
## OMEGA's:
## name index index2 value fix type
## 1 K 1 1 15 FALSE cv%
## SIGMA's:
## # A tibble: 0 × 0
## No variance-covariance matrix
##
## Compartments:
## A_CENTRAL (CMT=1)
Interestingly, the name of a compartment can be replaced as follows:
model %>% replace(Compartment(1, name="CENT")) %>%
delete(Ode("A_CENTRAL")) %>%
add(Ode("A_CENT", "-K*A_CENT"))
## [MAIN]
## K=THETA_K*exp(ETA_K) # Elimination constant
##
## [ODE]
## d/dt(A_CENT)=-K*A_CENT
##
## [LAG]
## A_CENT=2
##
## [RATE]
## A_CENT=100
##
##
## THETA's:
## name index value fix
## 1 K 1 0.06 FALSE
## OMEGA's:
## name index index2 value fix type
## 1 K 1 1 15 FALSE cv%
## SIGMA's:
## # A tibble: 0 × 0
## No variance-covariance matrix
##
## Compartments:
## A_CENT (CMT=1)