Some types of models carry around code that builds the input data for the
modeling, instead of relying on a single static file on disk. When necessary,
this function is called internally by submit_model()
to build the data
for running the model, but they can also be called manually by users for
other purposes.
build_data(.mod, .out_path = NULL, ...)
# S3 method for bbi_stan_model
build_data(.mod, .out_path = NULL, ...)
a bbi_{.model_type}_model
object.
If NULL
, the default, does not write any data to disk.
Otherwise, pass a file path where the resulting data object should be
written.
Arguments passed through to methods (currently none).
Invisibly returns the data object returned from the relevant build function.
Also optionally saves the object to disk if a valid file path is passed to
.out_path
.
The data object is returned invisibly because sometimes you will want to call this function solely for the side effect of writing the data to disk.
Currently, only bbi_stan_model
objects have this implemented.
The <run>-standata.R
file contains the code for building the Stan input
data.
build_data(bbi_stan_model)
: executes the function in <run>-standata.R
and
returns the list that will be passed to the data
argument of
cmdstanr::sample()
. Also optionally writes the returned data list to json
with cmdstanr::write_stan_json()
if an .out_path
is passed.