nlmixr2save 0.2.0
CRAN release: 2026-08-04
nlmixrDataSimplify()gainedestandcontrolarguments and no longer drops the covariate columns thatest="vae"searches for. The VAE covariate search picks its covariates out of the data instead of out of the model, so the candidate columns (as identified bynlmixr2est::vaeCovariates(), matched to thevaeControl()search options) are now kept in the simplified data and included in the hash. When the installednlmixr2estdoes not exportvaeCovariates()the search is skipped rather than erroring.-
You can now export a fit without the original data so a fitted model can be shared when the subject-level data cannot:
-
saveFit(fit, data = FALSE)(oroptions(nlmixr2save.data = FALSE)) writes a fit whoseorigDatais omitted from the zip. - New
nlmixr2saveShare()strips an existing saved fit (a live object or a.zipbase name; honorsnlmixr2save.dir/nlmixr2save.prefix) into a shareable sibling zip:fit-noData.zip(data removed) or, withnoFit = TRUE,fit-noData-noFit.zip(data and the returned prediction/residual table removed, keeping the model, estimates, eta table and parameter history). The original fit is left unchanged.
See
vignette("sharing-fits"), which also documents the side effects (e.g. VPC, residual re-derivation, and re-fitting need the original data). -
saveFit()no longer stores the redundantmodelelement (the loader always rebuilds it fromui). This removes a spurious “could not determine how to save object of class call for item model” warning when re-saving a previously loaded fit (including vianlmixr2saveShare()).-
Saved fits now record the
nlmixr2estandrxode2versions they were produced with (including each package’s commit sha when it was installed from a remote such as GitHub). When a fit is later loaded and the installednlmixr2estorrxode2differs:-
loadFit()warns that the fit was run with a different package version (controllable with the newcheckVersionargument). - the
:=caching operator, in an interactive session, asks whether to rerun the fit with the currently installed packages; non-interactively it loads the cached fit and warns. (Trusted-cache mode,nlmixr2save.check = FALSE, is left untouched so committed caches stay stable across versions.)
Fits saved by older
nlmixr2saveversions (which carry no version metadata) continue to load without any warning. The whole check can be turned off withoptions(nlmixr2save.checkVersion = FALSE)(or per call vialoadFit(..., checkVersion = FALSE)); it isTRUEby default. Seevignette("version-tracking"). -
The
parHistData$typefactor levels are now recorded from the fit at save time and restored on load, so the factor round-trips correctly regardless of whichnlmixr2estversion produced it (the level set has grown over versions, e.g."Analytic Gradient"). A hardcoded fallback covers fits saved before this was recorded.-
The
:=caching operator gains threeoptions()(mirroringnlmixr2save.quiet):-
nlmixr2save.prefix(default""): prepended to the assigned variable name to form the cache file, e.g. withoptions(nlmixr2save.prefix = "modelPiping-"),fit := nlmixr2(...)caches tomodelPiping-fit.zip. -
nlmixr2save.dir(default"."): the directory the cache files live in. -
nlmixr2save.check(defaultTRUE): whenTRUE,:=keeps verifying the cache against the current model/data/arguments (historical behavior); whenFALSE,:=simply loads the cache file if it exists (a fit as.zip, a simulation/other value as.rds) and otherwise runs and saves it – the cache is trusted and regenerated only when missing. This keeps a committed cache stable across nlmixr2/rxode2 versions.
-
New
nlmixr2saveInvalidate(): deletes every:=cache entry under the activenlmixr2save.prefix/nlmixr2save.dir, so cached fits/simulations are re-run on the next render whennlmixr2save.checkisFALSE.The saved-fit loader script now quotes its variable name, so a
nlmixr2save.prefixcontaining non-syntactic characters (e.g.-) round-trips correctly.Support both
$parFixedDfstructures produced by nlmixr2est: the current one (named “Estimate”/“SE” columns) and the upcoming$parFixedrefactor (nlmixr2est#645, unnamed columns). The structure of the fit is detected when it is saved and recorded in the restore script, so fits round-trip exactly with either version (nlmixr2saveParFixedDf()gained anamedargument; existing saved zip files continue to load unchanged).Additional all-
NAnumeric columns of$parFixedDf(for example “CI Lower”/“CI Upper” when there is no covariance step) are now coerced back to numeric when a saved fit is loaded, instead of being left as logical columns from the CSV round-trip.
nlmixr2save 0.1.0
CRAN release: 2026-06-17
Create zip files that are (mostly) R independent to save nlmixr2 fit items
Create a cached assignment operator
:=to save nlmixr2 fits automatically; if used, it will load a cached fit if function arguments are the same (a sort of disk memoization of the outermost function)Initial CRAN submission.
