Skip to contents

Compiles one of the built-in templates, your own mrgsolve code, or a model file, as the app's "Generate Model" button does.

Usage

mvp_model(
  template = NULL,
  code = NULL,
  file = NULL,
  params = NULL,
  ext_file = NULL,
  quiet = TRUE
)

Arguments

template

A template id or name from mvp_templates(), e.g. "2cmt".

code

mrgsolve model code (a single string).

file

Path to a model file: an mrgsolve .cpp (or .mod/text) file, code saved from the app's editor, or a NONMEM control stream. A NONMEM model is translated with 'nonmem2mrgsolve' when its .ext file is next to it (or given as ext_file) and the package is installed; otherwise use mvp_translate() (AI translation).

params

Optional named list of parameter values, e.g. list(CL = 3, VC = 10). Names must be parameters of the model (see mvp_params()).

ext_file

For a NONMEM file: its .ext file, if not next to it.

quiet

If FALSE, show mrgsolve's build messages.

Value

An mrgsolve model object (mrgmod), which can also be used with mrgsolve directly.

Details

Give exactly one of template, code or file. Compiling needs a C++ compiler (Rtools on Windows) and takes a few seconds. Each compiled model gets a unique name, so several models can be used side by side; a template is compiled once per R session and then reused. If the code does not compile, the error message holds the compiler's errors (also in the condition's details, class mvp_compile_error).

Examples

# \donttest{
if (interactive()) {
  mod <- mvp_model("2cmt", params = list(CL = 3, VC = 10))
  mvp_params(mod)
}
# }