This vignette attends to give a brief insight on the different
statements that may be used to build a structural model, compatible with
CAMPSIS.
The number of model statement types proposed in campsismod
is rather limited, with the underlying idea of keeping our model simple
and the translation to RxODE and mrgsolve as clean as possible. However,
in a near future, new types of model statements will likely be
supported.
Equations are described by 3 fields:
Example:
The equivalent text form is:
## KA=THETA_KA * exp(ETA_KA) # This is my KA parameter
Similarly, Ordinary differential equations (ODE’s) are described by 3 fields as well:
Example:
The equivalent text form is:
## d/dt(A_DEPOT)=-KA * A_DEPOT # This is my depot compartment
Line breaks can be added to a model to add clear separations between blocks of equations. It does not have any field.
Example:
The equivalent text form is obviously a separation line.
Comments can be specified at any place in the model. They have a unique field:
Example:
The equivalent text form is:
## # This is my first comment
If-statements allow a variable to take different values according to different specified conditions.
Example:
ifStatement <- IfStatement("COV==1", Equation("COV_EFFECT", "0.2"), comment="This is an if statement")
The equivalent text form is:
## if (COV==1) COV_EFFECT=0.2 # This is an if statement
A common use of the if-statements is to add covariate effects into the model. Here is an example:
main <- MainRecord()
main <- main %>%
add(Equation("COV_EFFECT", "0")) %>% # Initialisation
add(IfStatement("COV==1", Equation("COV_EFFECT", "0.1"))) %>% # Covariate value is 1 in dataset
add(IfStatement("COV==2", Equation("COV_EFFECT", "0.2"))) %>% # Covariate value is 2 in dataset
add(IfStatement("COV==3", Equation("COV_EFFECT", "0.3"))) # Covariate value is 3 in dataset
The equivalent text would then be:
## [MAIN]
## COV_EFFECT=0
## if (COV==1) COV_EFFECT=0.1
## if (COV==2) COV_EFFECT=0.2
## if (COV==3) COV_EFFECT=0.3
Please note that mrgsolve require all extra variables (like COV_EFFECT in the previous example) to be initialised to a predefined value, which makes a lot of sense in general.
Package campsismod
does not check the equations from a
grammar point of view. This work is delegated to the simulation engine
(RxODE or mrgsolve) and C compiler.
In general, respecting the few rules listed below will give you a successful compatibility with both engines: