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,
  .description,
  .based_on_additional = NULL,
  .add_tags = NULL,
  .inherit_tags = FALSE,
  .update_model_file = TRUE,
  .overwrite = FALSE,
  .directory = get_model_directory()
)

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

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

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

Arguments

.parent_mod

Model to copy from

.new_model

Path to write new model files to WITHOUT FILE EXTENSION. Function will create both {.new_model}.yaml and a new model file based on this path.

.description

Description of new model run. This will be stored in the yaml (to be used 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

.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

If TRUE, the default, update the newly created model file with new description and name. For a NONMEM model, this currently means only the $PROBLEM line in the new control stream will be updated. If FALSE, new model file will be an exact copy of its parent.

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

.directory

Model directory which .new_model is relative to. Defaults to options('rbabylon.model_directory'), which can be set globally with set_model_directory().

Methods (by class)

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

  • character: Takes a file path to parent model to use as a basis for the copy. Ideally a YAML path, but can also pass control stream or output directory. Can be absolute or relative to .directory, which defaults to options('rbabylon.model_directory').

  • numeric: Both .parent_mod and .new_model take integers which must correspond to a model file name (without extension obviously). This will only work if you are calling from the same directory as the models, or if you have set options('rbabylon.model_directory') to the directory constaining the relevant models.