Run model in NONMEM
run_nlme.RdRun 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,
tables = NULL,
full_tables = FALSE,
id,
path = getwd(),
method = c("nmfe", "pharmpy", "psn"),
nmfe = get_nmfe_location(),
force = NULL,
console = FALSE,
save_fit = TRUE,
save_summary = TRUE,
estimation_method = NULL,
sir_options = NULL,
auto_stack_encounters = TRUE,
clean = TRUE,
as_job = FALSE,
save_final = TRUE,
check_only = FALSE,
remove_tables = FALSE,
verbose = TRUE
)Arguments
- model
pharmpy model object or NONMEM model code (character) or path to NONMEM model file.
- data
filename of dataset or data.frame as input to NONMEM / nlmixr. Optional, can also be included in
modelobject (if specified as pharmpy model object).- tables
acharacter vector of which default tables to add, options are
fitandparameters. Default is NULL, i.e. don't add any new tables (but will keep existing).- full_tables
For the default tables, should all input columns from be included in the output tables? Default
FALSE.- 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 folderrun1in 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
pharmpydispatch,nmfeorpsn(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? DefaultFALSE.- console
show stderr and stdout in R console? If FALSE, will stream to files
stdoutandstderrin 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 asfit_summary_<id>.txtandfit_parameters_<id>.csv.- estimation_method
Optional. Character vector of estimation method(s) to apply to model. Will remove all existing estimation steps in the model and update with methods specified in argument.
- sir_options
options for running SIR in covariance step. A list with options
niter(number of SIR iterations) andsamples(number of samples). DefaultNULLleaves the model unchanged.samplesshould be between 300 and 10000 (suggested to use 1000 by default).nitershould be 1 or higher (suggest to use 1 by default).- auto_stack_encounters
only invoked if
dataargument supplied as a data.frame, not if a pharmpy model object is supplied withoutdataor whendatais a filename. 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?
- save_final
after running the model, should a file
final.modbe created with the final estimates from the run.- check_only
if
TRUE, will only check the model code (NM-TRAN in the case of NONMEM), but not run the model. Will returnTRUEif model syntax is correct, andFALSEif not. Will also attach stdout asmessageattribute.- remove_tables
if
TRUE, removes all$TABLErecords from the model before running. Applied after any tables added via thetablesargument. Default isFALSE.- verbose
verbose output?