Run a simulation based on supplied parameters estimates, and combine into proper format for VPC
create_vpc_data.RdThis rewrite of create_vpc_data() removes the Pharmpy/pharmr dependency
from every step that runs before run_nlme(). The only Pharmpy touch is
reading model$code as a string when a Pharmpy model is supplied. All
subsequent manipulation of the NONMEM code (parameter updates, record
removal/insertion, $EST -> $SIM conversion) and the input dataset
(sanitisation of string-typed columns) is done in pure R, so the
Python/R <-> reticulate serialisation cannot reject a value that NONMEM
itself would accept. run_nlme() is still used to actually invoke nmfe,
and post-processing of obs/sim is identical to the original.
Usage
create_vpc_data(
fit = NULL,
model = NULL,
data = NULL,
parameters = NULL,
keep_columns = c(),
n = 100,
verbose = FALSE,
id = NULL,
use_pharmpy = TRUE,
fix_input_heuristic = TRUE,
seed = NULL
)Arguments
- fit
fit object from
pharmr::run_modelfit(). Optional; alternative tomodel+parameters.- model
Either a Pharmpy model object (its
$codeis read), a character vector of NONMEM model code, or a path to a.modfile.- data
Path to the NONMEM-ready CSV. Optional; if missing, the function reads
$DATAfrom the model code.- parameters
Named list of parameter inits, e.g.
list(THETA_1 = 0.23, OMEGA_1_1 = 0.097, SIGMA_1_1 = 1). Optional.- keep_columns
character vector of column names in the original dataset to keep in the output.
- n
number of simulation iterations.
- verbose
verbose output?
- id
run id used as folder name. Defaults to a random name.
- use_pharmpy
retained for backward compatibility; controls whether
PRED/TADare transferred from obs to sim during post-processing.- fix_input_heuristic
If TRUE (default), detect the common
pharmr::set_dataset()side-effect that rewrites$INPUTto the CSV headers, and rebindTIME->TAFDand (for log-transform-both-sides models)DV->LNDV. Set to FALSE to leave$INPUTuntouched. The LTBS detection only scans the$ERRORrecord (not the whole model) so aLOG()call in a covariate transform doesn't trigger a false swap.- seed
integer seed passed to the simulation step. Default
NULLdraws a random seed per call (so repeatedcreate_vpc_data()calls in one session aren't pinned to identical draws); supply a value for bit-reproducible runs.