Skip to contents

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.

Value

the path of the written .zip, invisibly.

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.

See also

Author

Matthew L. Fidler

Examples

# \donttest{
  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
    })
  }
#>  
#>  
#>  
#>  
#>  parameter labels from comments are typically ignored in non-interactive mode
#>  Need to run with the source intact to parse comments
#> → Calculating residuals/tables
#>  done
#>  saving fit item: .fdFullCov
#>  saving fit item: .fdFullS
#>  saving fit item: .rownum
#>  saving fit item: AIC
#>  saving fit item: BIC
#>  saving fit item: R
#>  saving fit item: R.0
#>  saving fit item: R.E
#>  saving fit item: R.pd
#>  saving fit item: Rinv
#>  saving fit item: S
#>  saving fit item: S.E
#>  saving fit item: S.pd
#>  saving fit item: S0
#>  saving fit item: Sper
#>  saving fit item: aqHi
#>  saving fit item: aqLow
#>  saving fit item: aqn
#>  saving fit item: censInformation
#>  saving fit item: cholR
#>  saving fit item: cholS
#>  saving fit item: conditionNumberCor
#>  saving fit item: conditionNumberCov
#>  saving fit item: convergence
#>  saving fit item: cov
#>  saving fit item: covLvl
#>  saving fit item: covMethod
#>  saving fit item: covR
#>  saving fit item: covRS
#>  saving fit item: covS
#>  saving fit item: eigenCor
#>  saving fit item: eigenCov
#>  saving fit item: eigenVecCor
#>  saving fit item: eigenVecCov
#>  saving fit item: est
#>  saving fit item: etaObf
#>  saving fit item: extra
#>  saving fit item: fixef
#>  saving fit item: foceiControl0
#>  saving fit item: foceiModel
#>  saving fit item: fullCor
#>  saving fit item: iniDf0
#>  saving fit item: llikObs
#>  saving fit item: logLik
#>  saving fit item: message
#>  saving fit item: method
#>  saving fit item: mixIdx
#>  saving fit item: nAGQ
#>  saving fit item: nEstOmega
#>  saving fit item: nobs
#>  saving fit item: nsub
#>  saving fit item: objDf
#>  saving fit item: objective
#>  saving fit item: ofvType
#>  saving fit item: omega
#>  saving fit item: optReturn
#>  saving fit item: origData
#>  saving fit item: parFixed
#>  saving fit item: parFixedDf
#>  saving fit item: parHistData
#>  saving fit item: phiC
#>  saving fit item: phiH
#>  saving fit item: qfirst
#>  saving fit item: qw
#>  saving fit item: qx
#>  saving fit item: ranef
#>  saving fit item: runInfo
#>  saving fit item: scaleInfo
#>  saving fit item: sessioninfo
#>  saving fit item: shrink
#>  saving fit item: table
#>  saving fit item: time
#>  saving fit item: tolFactor
#>  saving fit item: ui
#>  zipping fit files
#>  removing unzipped fit files
#>  loading fit from fit.R
#> lotri syntax error:
#> =================================================================================
#> :001: tka ~ c(tka = 0.0367813010669496)
#> :002: tcl ~ c(tka = -0.000782456725690811, tcl = 0.0069543545026029)
#> :003: tv ~ c(tka = 0.000952366834165392, tcl = -0.000489959598361193, tv = 0.00218330787936497)
#> :004: add.sd ~ c(tka = -6.41258631708858e-05, tcl = -5.67004131128066e-05, tv = 3.82936894597721e-05, add.sd = 0.00243929995816957)
#> lotri error:
#>    matrix expression should be 'name ~ c(lower-tri)'
#> :005: om.eta.ka ~ c(tka = 0.000146993075376898, tcl = 0.000126165231341427, tv = -0.000127191366433412, add.sd = -0.000541130240379496, om.eta.ka = 0.0353763038424305)
#> lotri error:
#>    number named variables and lower triangular matrix size do not match
#>      did you mean something like:
#>      'om.eta.cl + varName2 + varName3 ~ c(-0.000117433625253258, 
#>                                           0.000125380229779247, -6.81577112109223e-05, 
#>                                           9.82139979915425e-06, -0.00012172625636792, 0.00118026544368931)
#> :006: om.eta.cl ~ c(tka = -0.000117433625253258, tcl = 0.000125380229779247, tv = -6.81577112109223e-05, add.sd = 9.82139979915425e-06, om.eta.ka = -0.00012172625636792, om.eta.cl = 0.00118026544368931)
#> lotri error:
#>    matrix expression should be 'name ~ c(lower-tri)'
#> :007: om.eta.v ~ c(tka = 7.85881365155322e-05, tcl = -3.00853221214718e-05, tv = 5.01075513373757e-05, add.sd = -2.91997524119011e-05, om.eta.ka = 0.000117120738078429, om.eta.cl = -8.31373925204361e-05, om.eta.v = 0.000124134785919267)
#> =================================================================================
#> Error: lotri syntax errors above
# }