The method run launches LibBi with a particular set of command line #' arguments. Normally, this function would not be run by the user, but instead one of the client functions sample, filter, or optimise, or rewrite, which pass any options on to run. Note that any options specified here are stored in the libbi object and do not have to be specified again if another command is run on the object.
# S3 method for libbi
run(x, client, proposal = c("model", "prior"), model, fix,
options, config, add_options, log_file_name, stdoutput_file_name, init, input,
obs, time_dim, working_folder, output_all, sample_obs, thin, chain = TRUE,
seed = TRUE, ...)a libbi object
client to pass to LibBi
proposal distribution to use; either "model" (default: proposal distribution in the model) or "prior" (propose from the prior distribution)
either a character vector giving the path to a model file (typically ending in ".bi"), or a bi_model object; by default, will use any model given in x
any variable to fix, as a named vector
list of additional arguments to pass to the call to LibBi. Any arguments starting with `enable`/`disable` can be specified as boolean (e.g., `assert=TRUE`). Any `dry-` options can be specified with a `"dry"` argument, e.g., `parse="dry"`. Any options that would be specified with `with`/`without` can be specified as character vector to an option named `with`/`without`, respectively, e.g. with="transform-obs-to-state".
path to a configuration file, containing multiple arguments
deprecated, replaced by options
path to a file to text file to report the output of LibBi
deprecated; use log_file_name instead
initialisation of the model, either supplied as a list of values and/or data frames, or a (netcdf) file name, or a libbi object which has been run (in which case the output of that run is used as input). If the object given as x has been run before, it will be used here with init-np set to the last iteration of the previous run, unless init is given explicitly.
input of the model, either supplied as a list of values and/or data frames, or a (netcdf) file name, or a libbi object which has been run (in which case the output of that run is used as input)
observations of the model, either supplied as a list of values and/or data frames, or a (netcdf) file name, or a libbi object which has been run (in which case the output of that run is used as observations)
The time dimension in any R objects that have been passed (init, input) and obs); if not given, will be guessed
path to a folder from which to run LibBi; default to a temporary folder.
logical; if set to TRUE, all parameters, states and observations will be saved; good for debugging
logical; if set to TRUE, will sample observations
any thinning of MCMC chains (1 means all will be kept, 2 skips every other sample etc.); note that LibBi itself will write all data to the disk. Only when the results are read in with bi_read will thinning be applied.
logical; if set to TRUE and x has been run before, the previous output file will be used as init file, and init-np will be set to the last iteration of the previous run. This is useful for running inference chains.
Either a number (the seed to supply to LibBi), or a logical variable: TRUE if a seed is to be generated for LibBi, FALSE if LibBi is to generate its own seed
any unrecognised options will be added to options
a libbi object, except if client is 'rewrite', in which case a bi_model object will be returned
# NOT RUN {
bi_object <- libbi(model = system.file(package="rbi", "PZ.bi"))
# }
# NOT RUN {
run(bi_object, options=list(client="sample", sample="smc2"))
# }
# NOT RUN {
if (bi_object$run_flag) {
bi_file_summary(bi_object$output_file_name)
}
# }
Run the code above in your browser using DataLab