Create new model by copying existing model. Useful for iterating during model development. Also fills based_on field by default, for constructing model ancestry. See "Using based_on field" vignette for details.

copy_model_from(
  .parent_mod,
  .new_model = NULL,
  .description = NULL,
  .based_on_additional = NULL,
  .add_tags = NULL,
  .star = NULL,
  .inherit_tags = FALSE,
  .update_model_file = TRUE,
  .overwrite = FALSE
)

# S3 method for bbi_nonmem_model
copy_model_from(
  .parent_mod,
  .new_model = NULL,
  .description = NULL,
  .based_on_additional = NULL,
  .add_tags = NULL,
  .star = NULL,
  .inherit_tags = FALSE,
  .update_model_file = TRUE,
  .overwrite = FALSE
)

Arguments

.parent_mod

Model to copy from

.new_model

Path to the new model, either absolute or relative to the path to .parent_mod. Represents an absolute model path, which is the path to the YAML file and model file, both without extension, and the output directory (once the model is run). Numeric values will be coerced to character. If NULL, the default, will try to increment to the next integer in the destination directory. See examples for usage.

.description

Character scalar description of new model run. This will be stored in the yaml (and can be viewed later in run_log()).

.based_on_additional

Character vector of path(s) to other models that this model was "based on." These are used to reconstuct model developement and ancestry. Paths must be relative to .new_model path. Note that the .parent_model will automatically be added to the based_on field, so no need to include that here.

.add_tags

Character vector with any new tags(s) to be added to {.new_model}.yaml

.star

Boolean, marks model to indicate special interest level.

.inherit_tags

If FALSE, the default, new model will only have any tags passed to .add_tags argument. If TRUE inherit any tags from .parent_mod, with any tags passed to .add_tags appended.

.update_model_file

Only relevant to NONMEM models. If TRUE, the default, update the newly created model file. If FALSE, new model file will be an exact copy of its parent. For a NONMEM model, this currently means only the $PROBLEM line in the new control stream will be updated to read See {.new_model}.yaml. Created by bbr..

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

Methods (by class)

  • copy_model_from(bbi_nonmem_model): .parent_mod takes a bbi_nonmem_model object to use as a basis for the copy.

Examples

if (FALSE) {
parent <- read_model("/foo/parent")

# create model file at /bar/child.ctl and YAML at /bar/child.yaml
copy_model_from(parent, "/bar/child", "child model with absolute path")

# create model file at /foo/child.ctl and YAML at /foo/child.yaml
copy_model_from(parent, "child", "relative to parent model path")

mod1 <- read_model("/path/to/1")

# create model file at /path/to/2.ctl and YAML at /path/to/2.yaml
copy_model_from(mod1, "increments to next integer by default")

# create model file at /path/to/3.ctl and YAML at /path/to/3.yaml
copy_model_from(mod1, 3, "numeric input works")

# create model file at /path/to/100.1.ctl and YAML at /path/to/100.1.yaml
copy_model_from(mod1, 100.1, "a period is okay")
}