Changelog
pharmr.extra (development version)
run_nlme()SAEM fits of nlmixr2 models no longer fail when the model was modified by a pharmpy operation aftercreate_model()(e.g.create_model(...) |> set_initial_estimates(...)). Such operations return a new pharmpy object that drops the SAEM-safenlmixr_codeattribute cached bycreate_model();run_nlme_nlmixr()now reapplies the residual-alias rewrite to the fallbackmodel$codeso SAEM accepts the residual error formula.create_model(tool = "nlmixr2")no longer aborts withValueError: datainfo.path is Nonewhendatais supplied as a data.frame.clean_modelfit_data()was callingpharmr::load_dataset()afterset_dataset(); the reload was redundant (the dataset is already attached) and failed for nlmixr2 models, whose datainfo has no on-disk path.create_model()now writes a data.framedataargument to a CSV in the session tempdir and points the model’s$DATArecord at that file, instead of leaving pharmpy’sDUMMYPATHplaceholder. This gives the model an on-disk dataset, which is required to use therun_nlme(copy_dataset = FALSE)workflow (NONMEM models only; filename input already has an on-disk dataset).copy_dataset = FALSEcan only be honored when the dataset is a file on disk (supplied viadataor referenced by the model’s$DATArecord). When only an in-memory dataset is available (a passed data frame,model$dataset, or the original dataset), a warning is issued and the dataset is copied into the run folder (with$DATArewritten) as a fallback.copy_dataset = FALSEnow leaves the model’s$DATArecord untouched instead of rewriting it to the dataset’s absolute path. Combined with not copying the dataset into the run folder, the model’s original data reference is preserved verbatim. ($DATAis still rewritten whencopy_dataset = TRUE, i.e. when the dataset is placed into the run folder asdata.csv.)run_nlme(data = NULL, copy_dataset = FALSE)now correctly leaves the dataset in its existing location when the model’s$DATArecord points to a real file. Previously the dataset was always copied into the run folder becauserun_nlme()materialisedmodel$datasetinto a tempfile before reachingprepare_run_folder(), andprepare_run_folder()preferred the in-memory dataset over the on-disk $DATA path.update_parameters()now also accepts a rawnlmixr2FitCore/nlmixr2FitDataobject — useful when fitting outsiderun_nlme(). Both diagonal and off-diagonal omega elements are extracted and named per pharmpy’sIIV_X/IIV_X_IIV_Yconvention, so block-omega covariances are now updated alongside variance terms (previously dropped).run_nlme(),run_sim(), andcreate_vpc_data()now dispatch on the model engine. Pharmpy nlmixr-format models are routed through nlmixr2 / rxode2 directly (no pharmpypyreadrdependency). NONMEM models still use the existing nmfe / PsN / pharmpy paths unchanged.New
controlargument onrun_nlme()is forwarded tonlmixr2::nlmixr2()(e.g.foceiControl()); ignored for NONMEM.validate_model()now accepts nlmixr-format pharmpy models.get_advan()/get_obs_compartment()return gracefully for non-NONMEM models instead of erroring on the missing control stream.add_sir()now warns and no-ops for non-NONMEM models instead of silently doing nothing or aborting deep inside the covariance-record reader.call_pharmpy_tool()now forwardsesttool = "nlmixr"to pharmpy when a search tool (modelsearch,covsearch,iivsearch,ruvsearch,amd,bootstrap) is invoked with an nlmixr-format model. Pharmpy can drive these searches against nlmixr2 if the Python packagepyreadris installed and the system Rscript that pharmpy spawns has a working nlmixr2 / data.table install.compare_nlme_runs()now detects the engine per run folder and loads nlmixr2 fits from the saved<id>.rdsnext to the run directory, socompare_nlme_runs()works for nlmixr2 runs too.create_modelfit_info_table()is robust to fit objects reloaded from RDS whose pharmpy model attribute is no longer a live Python reference.create_vpc_data()on an nlmixr fit now uses the fitted model’s parameter estimates (was silently falling back to the pre-fit initial estimates when only afitwas supplied), and restrictsobsto observation rows so it matches the simulation row set.run_nlme_nlmixr()now stashes an explicitdataargument on the model so saved fits sim/VPC against the right dataset (previously the saved model still referenced the originalmodel$dataset).Initial CRAN submission.