ferx_simulate.RdSimulates observations from a parsed model with between-subject variability
and residual error. When a fit is supplied, the fitted theta, omega,
and sigma replace the model file's initial values — which is the usual flow
after ferx_fit (e.g. for posterior-predictive checks or VPCs).
ferx_simulate(model, data, n_sim = 1L, seed = 42L, fit = NULL)Path to a .ferx model file
Path to a NONMEM-format CSV (provides population structure: doses, obs times)
Number of simulation replicates
Random seed for reproducibility
Optional ferx_fit result. When provided, simulation uses
fit$theta, fit$omega, and fit$sigma instead of the
model file's initial values.
A data.frame with columns: SIM, ID, TIME, IPRED, DV_SIM
ex <- ferx_example("warfarin")
fit <- ferx_fit(ex$model, ex$data, method = "gn", covariance = FALSE)
#> Warning: Model file [fit_options] sets `method = foce` but ferx_fit() argument overrides it with `gn`. The call-time value will be used.
#> Warning: Model file [fit_options] sets `covariance = true` but ferx_fit() argument overrides it with `false`. The call-time value will be used.
#> Mu-referencing detected for: ETA_CL, ETA_KA, ETA_V
#> Negative IWRES autocorrelation detected (Durbin-Watson = 2.61, lag-1 r = -0.37).
#> Possible over-parameterisation or misspecified residual error model.
sim <- ferx_simulate(ex$model, ex$data, n_sim = 10L, seed = 1L, fit = fit)
head(sim)
#> DRAW SIM ID TIME IPRED DV_SIM
#> 1 1 1 1 0.5 3.563045 3.539832
#> 2 1 1 1 1.0 6.032609 5.974273
#> 3 1 1 1 2.0 8.892847 9.074113
#> 4 1 1 1 4.0 10.703127 10.685702
#> 5 1 1 1 8.0 10.474217 10.522614
#> 6 1 1 1 12.0 9.659228 9.664573