Create and submit a new bbi_nmsim_model object, which is then attached to
the existing bbi_nonmem_model object
Usage
add_simulation(
.mod,
n = 200,
seed = 1234,
data = NULL,
sim_cols = c("DV", "PRED"),
gitignore_sim = getOption("bbr.gitignore_sim"),
.join_col = "NUM",
.inherit_tags = TRUE,
.bbi_args = NULL,
.mode = getOption("bbr.bbi_exe_mode"),
...,
.overwrite = NULL,
.config_path = NULL,
.wait = TRUE,
.dry_run = FALSE
)
has_simulation(.mod)
get_simulation(.mod)Arguments
- .mod
A
bbi_nonmem_modelorbbi_nonmem_summaryobject- n
Number of simulations/subproblems. Adds
SUBPROBLEMS=nto a$SIMULATIONrecord.- seed
A seed for simulation. Appended to
$SIMULATIONrecord.- data
A dataset to simulate from. Defaults to
NULL, which will use use the original data. If provided, must include the same column names as what's returned fromnm_data(.mod).- sim_cols
Character column name(s) defining the simulated values to table out.
- gitignore_sim
If
TRUE, the default, add the simulation output directory to a.gitignorefile. The intention here is to avoid committing large files (i.e. large simulation tables). This can be passed directly to this argument or set globally withoptions("bbr.gitignore_sim").- .join_col
Character column name(s) used to join table files post execution. Gets appended to the generated
$TABLErecord. Seenm_join_sim()documentation for details. Defaults to'NUM'.If
TRUE, the default, inherit any tags from.mod.- .bbi_args
A named list specifying arguments to pass to bbi formatted like
list("nm_version" = "nm74gf_nmfe", "json" = T, "threads" = 4). Runprint_bbi_args()to see valid arguments. Note that bbr does not support changing the output directory (including through the model or global YAML files).- .mode
Mode for model submission: "local", "sge", or "slurm". If unspecified, the value is set to the value of the
bbr.bbi_exe_modeoption. This option defaults to "sge" on Linux and "local" otherwise.- ...
args passed through to
bbi_exec()- .overwrite
Logical to specify whether or not to overwrite existing model output from a previous run. If
NULL, the default, will defer to setting in.bbi_argsorbbi.yaml. If notNULLwill override any settings in.bbi_argsorbbi.yaml.- .config_path
Path to a bbi configuration file. If
NULL, the default, will attempt to use abbi.yamlin the same directory as the model.- .wait
If
TRUE, the default, wait for the bbi process to return before this function call returns. IfFALSEfunction will return while bbi process runs in the background.- .dry_run
Returns an object detailing the command that would be run, insted of running it. This is primarily for testing but also a debugging tool.
Details
add_simulation does the following things:
Checks that
.modwas previously executed and tabled out anMSFfile (i.e.$EST MSFO=1.MSF).Note: If you are using
bbi <= 3.3.0, theMSFfile must have an upper case extension. By default,bbi <= 3.3.0will delete.msf(lower case) files upon model completion.
Performs various checks to confirm the status of
.mod, the contents of its control stream, and the input data.Creates a new
bbi_nmsim_modelobject with the following differences from the original control stream:Removes the following record types for simulation:
$EST,$COV,$TABLE,$SIMULATIONRemoves PK and prior records:
$PRIOR,$THETA/$THETAP/$THETAPV,$OMEGA/$OMEGAP/$OMEGAPD,$SIGMA/$SIGMAP/$SIGMAPDAdds a new custom
$SIMULATIONrecord using user specified values (e.g.seedandn).TRUE=FINALis appended to ensure the final values are used rather than the initial estimates.ONLYSIMULATIONflag is appended to reduce run times.
Adds a new
$TABLErecord tabling out simulated values (sim_cols) and.join_colcolumn(s)Adds a new
$MSFIrecord (run withNOMSFTEST) pointing to theMSFfile of.mod
Creates a specification file, storing
seeds,n, and other various items helpful for traceability purposes.Submits the model for execution.
Functions
add_simulation(): Add a simulation to abbi_nonmem_modelobjecthas_simulation(): Helper for determining if abbi_nonmem_modelhas a simulation attached to it. ReturnsTRUEif abbi_nmsim_modelspecification file is found within the output directory of.mod, andFALSEotherwise.get_simulation(): Read in and return abbi_nmsim_modelobject stored within the output directory of.mod.
Re-running existing simulation
By default, the output directory of the simulation is gitignore'd (see
gitignore_sim argument). When a collaborator attempts to read in the parent
model, they would see it has an attached simulation with a status of "Not Run".
To re-run this simulation using the specs that were originally used, you can simply execute the following commands:
This will execute the simulation using the same n, seed, and data that
were provided by the collaborator.
