Save a ferx fit to a portable

Description

Writes a single, self-describing zip archive that any language with stdlib JSON + CSV + zip readers can open (R, Python, Julia, Rust). The archive includes parameter estimates, per-subject EBEs, per-observation predictions, and the verbatim .ferx model source.

Usage

ferx_save_fit(fit, output, include_data = FALSE)

Arguments

  • fit: A ferx_fit object returned by [ferx_fit](ferx_fit.qmd).
  • output: Path to write. By convention the file extension is .fitrx; the function does not enforce this.
  • include_data: Logical. When TRUE, the input NONMEM CSV used to fit the model is embedded verbatim inside the archive (as data.csv). Requires that the file is still accessible at the path captured at fit time (fit$data_path). Default FALSE.

Details

The schema is shared with the ferx-core Rust crate; see its docs/src/file-formats/fitrx.md for the full field reference.

Seealso

[ferx_load_fit](ferx_load_fit.qmd), [ferx_fit](ferx_fit.qmd) (and its output argument for save-during-fit). Other utilities: [ferx_columns](ferx_columns.qmd)(), [ferx_example](ferx_example.qmd)(), [ferx_load_fit](ferx_load_fit.qmd)()

Concept

utilities

Value

Invisibly returns fit, so the function can be used inside a pipe without breaking the chain:

fit |> ferx_save_fit("run1.fitrx") |> ferx_estimates()

Examples

ex  <- ferx_example("warfarin")
fit <- ferx_fit(ex$model, ex$data, method = "gn", covariance = FALSE)
tmp <- tempfile(fileext = ".fitrx")
ferx_save_fit(fit, tmp)
fit2 <- ferx_load_fit(tmp)
identical(fit$theta, fit2$theta)