new_sim_model: Create a simulation model object from an existing model

View source: R/vpc-simulation.R

new_sim_modelR Documentation

Create a simulation model object from an existing model

Description

Create a simulation model object from an existing model

Usage

new_sim_model(
  .mod,
  n = 200,
  seed = 1234,
  data = NULL,
  sim_cols = c("DV", "PRED"),
  gitignore_sim = getOption("bbr.gitignore_sim"),
  .join_col = "NUM",
  .sim_dir = get_output_dir(.mod),
  .inherit_tags = TRUE,
  .overwrite = FALSE
)

make_sim_spec(.sim, sim_args, .overwrite = FALSE)

Arguments

.mod

a bbi_nonmem_model object.

n

Number of simulations/subproblems. Adds SUBPROBLEMS=n to a ⁠$SIMULATION⁠ record.

seed

A seed for simulation. Appended to ⁠$SIMULATION⁠ record.

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 from nm_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 .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").

.join_col

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'.

.sim_dir

A directory for holding the new simulation model. Defaults to the output directory of .mod.

.inherit_tags

If TRUE, the default, inherit any tags from .mod.

.overwrite

If FALSE, the default, function will error if a model file already exists at specified .new_model path. If TRUE any existing file at .new_model will be overwritten silently.

.sim

a bbi_nmsim_model object

sim_args

named list defining the seed, and n simulations.

Value

S3 object of class bbi_nmsim_model.

Functions

  • make_sim_spec(): Store simulation run details in a specification file before submission, which is stored in the output directory of the parent model.

Examples

## Not run: 

# Create new `nmsim` model object
.sim <- new_sim_model(
  .mod,
  n = 500, seed = 1234,
  .join_col = c("NUM", "ID")
)

# Store run details in specification file
#  - this is why these functions aren't exported
make_sim_spec(
  .sim,
  sim_args = list(n = 500, seed = 1234),
 .join_col = c("NUM", "ID")
)

# Visualize changes
model_diff(.sim)

# Submit
submit_model(.sim)

## End(Not run)


metrumresearchgroup/bbr documentation built on March 29, 2025, 1:08 p.m.