nlmixr2saveShare: Save a shareable copy of a fit without the original data

View source: R/save.R

nlmixr2saveShareR Documentation

Save a shareable copy of a fit without the original data

Description

Writes a portable .zip copy of a saved fit that omits the original dataset (the subject-level data), so a fitted model can be shared without its data. The input may be a live fit object or the base name of an existing saved fit .zip; either way the original is left unchanged and new sibling zips are written. Names are resolved through getOption("nlmixr2save.dir") and getOption("nlmixr2save.prefix") (as for the ⁠:=⁠ cache).

Usage

nlmixr2saveShare(x, noFit = FALSE, file = NULL)

Arguments

x

a fitted model object, or the base name (no extension) of a saved fit .zip to read.

noFit

Boolean; when TRUE, also strip the output tables (the returned prediction/residual data.frame), writing ⁠<file>-noData-noFit.zip⁠ instead of ⁠<file>-noData.zip⁠.

file

optional output base name; defaults to the name of x.

Details

  • nlmixr2saveShare("fit") writes fit-noData.zip – the full fit (predictions and tables intact) with the original data removed.

  • nlmixr2saveShare("fit", noFit=TRUE) writes fit-noData-noFit.zip – the core fit only (model, parameter estimates, objective, omega, etaObf, parHistData), with both the original data and the returned prediction/residual table removed.

Value

the path of the written .zip, invisibly.

Author(s)

Matthew L. Fidler

See Also

saveFit(), loadFit()

Examples


  if (requireNamespace("nlmixr2est", quietly=TRUE) &&
        requireNamespace("nlmixr2data", quietly=TRUE) &&
        requireNamespace("withr")) {
    library(nlmixr2est)
    library(nlmixr2data)
    withr::with_tempdir({
      one.cmt <- function() {
        ini({
          tka <- 0.45; tcl <- log(c(0, 2.7, 100)); tv <- 3.45
          eta.ka ~ 0.6; eta.cl ~ 0.3; eta.v ~ 0.1
          add.sd <- 0.7
        })
        model({
          ka <- exp(tka + eta.ka); cl <- exp(tcl + eta.cl); v <- exp(tv + eta.v)
          linCmt() ~ add(add.sd)
        })
      }
      fit <- nlmixr2(one.cmt, theo_sd, est="focei")
      saveFit(fit)                       # fit.zip (with data)
      nlmixr2saveShare("fit")            # fit-noData.zip
      nlmixr2saveShare("fit", noFit=TRUE) # fit-noData-noFit.zip
    })
  }


nlmixr2save documentation built on Sept. 26, 2026, 1:07 a.m.