Write, run and rank the candidates of a model suggestion
Source:R/nm_suggest_run.R
nm_suggest_run.RdWrites the control streams of the chosen candidates of
nm_suggest_model() with nm_write_ctl() (from = x), launches them with
nm_run(), reads their objective function value and ranks them by BIC
(OFV + number of estimated parameters x log(number of observations)). The
rank by BIC is compared with the rank of the data-driven score (Spearman
correlation), which shows whether the suggestion anticipated the NONMEM
result. A lag time of a candidate is added after $PK as ALAG1 = THETA(n) with its initial value, since nm_write_ctl() writes none.
Usage
nm_suggest_run(
x,
analysis_dir,
nmfe_path = NULL,
candidates = 1:3,
prefix = "sugg",
data = NULL,
run = TRUE,
overwrite = FALSE,
verbose = TRUE,
n_cores = 1L,
...
)
# S3 method for class 'nm_suggest_run'
print(x, ...)Arguments
- x
An
nm_model_suggestionobject.- analysis_dir
Analysis directory where the control streams are written and run. It must contain the dataset, or
datamust point to it.- nmfe_path
Path to the nmfe launcher (see
nm_run()).- candidates
Candidate numbers (default: the first 3).
- prefix
Prefix of the control stream names (
<prefix><n>.ctl).- data
Dataset file name written in
$DATA(default: the file analysed bynm_suggest_model()), relative toanalysis_diror absolute.- run
If
FALSE, only the control streams are written.- overwrite
Replace existing control streams and adapted datasets, and run the candidates again even when a previous run of the same name has terminated (otherwise
nm_run()skips it and its old results are read).- verbose
Print progress messages.
- n_cores
Number of candidates run at the same time, passed to
nm_run()(default 1).- ...
Further arguments passed to
nm_write_ctl()(e.g.method).
Value
An object of class nm_suggest_run: a data.frame with one row
per candidate (candidate, model, score, rank_score, ctl,
data (dataset used), ofv, n_par, n_obs, bic, rank_bic,
min_ok), with the
Spearman correlation between score and BIC ranks in attribute
spearman and the nm_run() log in attribute log.
Details
Each candidate gets a dataset that matches its compartment numbering:
doses in the depot (CMT 1) and observations in the central compartment
(CMT 2) for first-order and transit absorption (ADVAN2/4/12 or ODE);
doses and observations in the central compartment (CMT 1) for IV and
zero-order input (ADVAN1/3/11), with RATE = -2 on the doses for a
modelled zero-order duration (D1). When the original dataset does not
match, a copy <data>_<prefix><n>.csv is written in analysis_dir
(records copied verbatim, only CMT and RATE changed); the original file
is never modified. Datasets with several observed compartments (parent
and metabolite, PK and PD) or doses by several routes are not handled:
the function stops.
Examples
if (FALSE) { # \dontrun{
s <- nm_suggest_model("C:/nm76g64/run/etude/data.csv")
r <- nm_suggest_run(s, analysis_dir = "C:/nm76g64/run/etude",
nmfe_path = "C:/nm76g64/run/nmfe76.bat", candidates = 1:4)
r
} # }