Skip to contents

Run the model directly using nmfe (not through pharmpy). This is a more reliable way of running NONMEM, and it is now possible to stream stdout and stderr to file or to console, which is useful for inspection of intermediate model fit.

Usage

run_nlme(
  model,
  data = NULL,
  id,
  path = getwd(),
  method = c("nmfe", "pharmpy", "psn"),
  nmfe = get_nmfe_location_for_run(),
  force = FALSE,
  console = FALSE,
  save_fit = TRUE,
  save_summary = TRUE,
  auto_stack_encounters = TRUE,
  clean = TRUE,
  as_job = FALSE,
  verbose = TRUE
)

Arguments

model

pharmpy model object or NONMEM model code (character) or path to NONMEM model file.

data

dataset (data.frame). Optional, can also be included in model object (if specified as pharmpy model object).

id

run id, e.g. run1. This will be the folder in which the NONMEM model is run. If no folder is specified, it will create a folder run1 in the current working directory, and will increment the run number for each subsequent run.

path

path to nonmem model. If not specified, will assume current working directory.

method

run method, either pharmpy dispatch, nmfe or psn (psn::execute).

nmfe

full path to nmfe file to run NONMEM with, if method=="nmfe".

force

if run folder (id) exists, should existing results be removed before rerunning NONMEM? Default FALSE.

console

show stderr and stdout in R console? If FALSE, will stream to files stdout and stderr in fit folder.

save_fit

save fit object. If TRUE, will save as <run_id.rds>. Can also specify filename (rds) to save to.

save_summary

save fit summary and parameter estimates to file? Default is TRUE. Will use current folder, and save as fit_summary_<id>.txt and fit_parameters_<id>.csv.

auto_stack_encounters

only invoked if data argument supplied, not if a pharmpy model object is supplied without data. Detects if TIME within an individual is decreasing from one record to another, which NONMEM cannot handle. If this happens, it will add a reset event (EVID=3) at that time, and increase the TIME for subsequent events so that NONMEM does not throw an error. It will increase the time for the next encounter to the maximum encounter length across all subjects in the dataset (rounded up to 100). If no decreasing TIME is detected, nothing will be done (most common case). This feature is useful e.g. for crossover trials when data on the same individual ispresent but is included in the dataset as time-after-dose and not actual time since first overall dose.

clean

clean up run folder after NONMEM execution?

as_job

run as RStudio job?

verbose

verbose output?

Details

The function does take a pharmpy model as input (optionally), and uses pharmpy to read the results from the model fit, and returns a pharmpy modelfit object.