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. When the path has no file extension, the conventional .fitrx extension is appended automatically (so "results/run1" is written as "results/run1.fitrx"); [ferx_load_fit](ferx_load_fit.qmd) accepts either the bare or the extended path. An explicit extension is honoured as given.
  • 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_example](ferx_example.qmd), [ferx_get_columns](ferx_get_columns.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") |> (\(f) f$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)