Model specifications

mapbayr contains a library of example model files (.cpp), accessible with exmodel(). You are invited to perform MAP-Bayesian estimation with your own models. These model files should be follow some specifications in order to be “read” by mapbayr.

1. $PARAM block

From mapbayr version 1.0.0, it is not needed to define ETAs in $PARAM anymore. If ETA1, ETA2 etc… are found in $PARAM, an error will be returned.

// Don't do this anymore
$PARAM ETA1 = 0, ETA2 = 0

Covariates

// Do this
$PARAM @covariates
BW = 70, SEX = 0

// Better
$PARAM @annotated @covariates
BW : 70 : Body weight (kg)
SEX : 0 : Sex (0=Male, 1=Female)

// Don't do this
$PARAM BW = 70, SEX = 0

2. $CMT block

//example: model with dual zero and first order absorption in compartment 1 & 2, respectively, and observation of parent drug + metabolite 
$CMT @annotated
DEPOT: Depot [ADM]
CENT_PAR: examplinib central [ADM, OBS]
PERIPH : examplinib peripheral
CENT_MET : methylexamplinib central [OBS] 

3. $OMEGA block

Define at least one $OMEGA block.

$OMEGA 0.123 0.456 0.789

Multiple blocks and all the options (e.g. correlation, block etc) are allowed.

$OMEGA @annotated
ECL : 0.123 : Clearance
ETA2 : 0.456 : Volume of distribution
FOO : 0.789 : Absorption rate constant
// reminder: Each ETA can be described with (`@annotated`)
// The labels (on the left-hand side) are not considered by mapbayr

4. $SIGMA block

The definition of the $SIGMA block may not be as straightforward as other blocks, but we tried to keep it as simple as possible. Keep in mind that mapbayr always expect a pair of sigma values for each type of dependent variable: the first value for proportional error, the second for additive.

Two situations can be distinguished:

  1. You only have one type of concentration to fit, and you did not use the [OBS] assignment in $CMT.

Simply write one pair of sigma values to describe proportional and additive error on your concentrations. This error model will be automatically applied to the compartment where observations were recorded in your dataset (i.e. value of CMT when MDV = 0).

$SIGMA 0.111 0 // proportional error 
$SIGMA 0 0.222 // (log) additive error
$SIGMA 0.333 0.444 // mixed error
  1. You have multiple types of DV (parent and metabolite), and/or you used the [OBS] assignment in $CMT.

Write as many pairs of sigma values as there are compartments assigned with [OBS] in $CMT. The order of the pair must respect the order in which compartments were assigned. To put it more clearly, the sigma matrix will be interpreted as such whatever the model :

N° in the SIGMA matrix diagonal Associated error
1 Proportional on concentrations in the 1st cmt with [OBS]
2 Additive on concentrations in the 1st cmt with [OBS]
3 Proportional on concentrations in the 2nd cmt with [OBS]
4 Additive on concentrations in the 2nd cmt with [OBS]
//example: correlated proportional error between parent and metabolite
$SIGMA @block
0.050 // proportional error on parent drug
0.000 0.000 // additive error on parent drug
0.100 0.000 0.200 // proportional error on metabolite
0.000 0.000 0.000 0.000 // additive error on metabolite
// reminder: sigma values can be recorded in multiple $SIGMA blocks

6. $TABLE block or $ERROR block

$TABLE
double DV  = (CENTRAL / VC) * exp(EPS(2)) ;
$TABLE
double PAR = (CENT_PAR / V) * (1 + EPS(1)) ;
double MET = (CENT_MET / V) * (1 + EPS(3)) ;
double DV = PAR ;
if(self.cmt == 4) DV = MET ; 
// reminder: use "self.cmt" to internaly refer to a compartment in a mrgsolve model code. 

Note that mapbayr does not strictly rely on this $ERROR block to define the residual error internally and compute the objective function value, but on information passed in the $SIGMA block. However, we strongly advise you to properly code your $ERROR block with EPS(1), EPS(2) etc…, if only to use your code as a regular mrgsolve model code and simulate random effects.

7. $MAIN block

From mapbayr version 1.0.0, it is not needed to duplicate expressions with ETAs in $MAIN anymore.

// Do this (as usual)
$MAIN
double CL = TVCL * exp(ETA(1)) ;

// Don't do this anymore
MAIN
double CL = TVCL * exp(ETA1 + ETA(1)) ;

8. $CAPTURE block

$CAPTURE DV PAR MET CL