This page provides an overview of the basic structure of NONMEM Bayes models
in bbr
. The main entry point for interacting with NONMEM Bayes models is
the bbi_nmbayes_model
object.
NONMEM models in bbr
have one control stream. Executing the model produces
an output directory. NONMEM Bayes models, on the other hand, have a more
complicated model structure. The user still defines only one control stream.
Underneath, this top-level control stream is then used to derive the control
stream of multiple submodels, one for the initial estimates and one for each
chain.
For a control stream with the base name run
,
submit_model() will create the following submodels:
<run>/init/
- A model that generates the initial estimates.
<run>/<run>-<chain>/
- A model for each chain that generates samples
using BAYES
or NUTS
estimation methods.
The first step to defining a NONMEM Bayes model will often be to call
copy_model_as_nmbayes()
on an existing non-Bayes NONMEM model. This creates
the new model with bbr::copy_model_from()
and then sets the model type to
"nmbayes". Alternatively you can also create a fresh NONMEM Bayes model with
new_model(..., .model_type = "nmbayes")
. (As with regular NONMEM models, a
control stream must already exist.)
The control stream must define the following two records:
a METHOD=CHAIN
estimation record that defines how to generate the
initial estimates for each chain. ISAMPLE
should be set to 0. The
NITER
option controls the number of chains.
a METHOD=BAYES
or METHOD=NUTS
estimation record to generate posterior
samples.
Here's an example that defines four chains of 500 samples: