Create and submit a new bbi_nmsim_model
object, which is then attached to
the existing bbi_nonmem_model
object
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)
A bbi_nonmem_model
or bbi_nonmem_summary
object
Number of simulations/subproblems. Adds SUBPROBLEMS=n
to a
$SIMULATION
record.
A seed for simulation. Appended to $SIMULATION
record.
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 from nm_data(.mod)
.
Character column name(s) defining the simulated values to table out.
If TRUE
, the default, add the simulation output directory
to a .gitignore
file. 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 with options("bbr.gitignore_sim")
.
Character column name(s) used to join table files post
execution. Gets appended to the generated $TABLE
record. See
nm_join_sim()
documentation for details. Defaults to 'NUM'
.
If TRUE
, the default, inherit any tags from .mod
.
A named list specifying arguments to pass to bbi
formatted like list("nm_version" = "nm74gf_nmfe", "json" = T, "threads" = 4)
. Run print_bbi_args()
to see valid arguments. Note that bbr does
not support changing the output directory (including through the model or
global YAML files).
Either "sge"
, the default, to submit model(s) to the grid or
"local"
for local execution. This can be passed directly to this argument
or set globally with options("bbr.bbi_exe_mode")
.
args passed through to bbi_exec()
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_args
or bbi.yaml
. If not NULL
will override any
settings in .bbi_args
or bbi.yaml
.
Path to a bbi configuration file. If NULL
, the
default, will attempt to use a bbi.yaml
in the same directory as the
model.
If TRUE
, the default, wait for the bbi process to return
before this function call returns. If FALSE
function will return while
bbi process runs in the background.
Returns an object detailing the command that would be run, insted of running it. This is primarily for testing but also a debugging tool.
add_simulation
does the following things:
Checks that .mod
was previously executed and tabled out an MSF
file
(i.e. $EST MSFO=1.MSF
).
Note: If you are using bbi <= 3.3.0
, the MSF
file must have
an upper case extension. By default, bbi <= 3.3.0
will 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_model
object with the following differences from
the original control stream:
Removes the following record types for simulation: $EST
, $COV
,
$TABLE
, $SIMULATION
Removes PK and prior records: $PRIOR
, $THETA/$THETAP/$THETAPV
,
$OMEGA/$OMEGAP/$OMEGAPD
, $SIGMA/$SIGMAP/$SIGMAPD
Adds a new custom $SIMULATION
record using user specified values (e.g.
seed
and n
).
TRUE=FINAL
is appended to ensure the final values are used rather
than the initial estimates.
ONLYSIMULATION
flag is appended to reduce run times.
Adds a new $TABLE
record tabling out simulated values (sim_cols
) and
.join_col
column(s)
Adds a new $MSFI
record (run with NOMSFTEST
) pointing to the MSF
file of .mod
Creates a specification file, storing seeds
, n
, and other various items
helpful for traceability purposes.
Submits the model for execution.
add_simulation()
: Add a simulation to a bbi_nonmem_model
object
has_simulation()
: Helper for determining if a bbi_nonmem_model
has a
simulation attached to it. Returns TRUE
if a bbi_nmsim_model
specification file is found within the output directory of .mod
, and
FALSE
otherwise.
get_simulation()
: Read in and return a bbi_nmsim_model
object stored
within the output directory of .mod
.
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.
if (FALSE) {
# Add a new simulation and submit for execution
add_simulation(
.mod,
n = 100,
.mode = "local",
.wait = FALSE
)
# Optionally read in simulation model object
if(has_simulation(.mod)){
.sim <- get_simulation(.mod)
}
}