ferx_sir.RdRun a Sampling Importance Resampling (SIR) uncertainty step against a
fit that was produced earlier — useful when the original fit was
expensive and you want to add SIR without re-estimating, or when working
with a fit loaded from a .fitrx bundle.
ferx_sir(
fit,
sir_samples = 1000L,
sir_resamples = 250L,
sir_seed = NULL,
sir_keep_samples = FALSE,
verbose = FALSE
)A ferx_fit object produced by ferx_fit() or
ferx_load_fit().
Number of proposal samples drawn from the asymptotic distribution. Higher values give tighter weights at proportional cost. Default 1000.
Number of resampled vectors. Must be <= sir_samples.
Default 250.
Integer RNG seed for reproducibility. NULL (the default)
uses the engine's built-in seed.
When TRUE, retain the resampled packed
parameter vectors on the returned fit. Required for
ferx_simulate_with_uncertainty() with method = "sir". Default
FALSE.
When TRUE, the engine prints progress to stderr.
Default FALSE.
The input fit, augmented with sir_ess, sir_ci_theta,
sir_ci_omega, sir_ci_sigma, and (when requested) sir_resamples /
sir_resamples_n / sir_resamples_dim.
ferx_sir() re-uses the fit's asymptotic covariance matrix as the SIR
proposal distribution and the per-subject empirical Bayes ETAs as
warm-starts for the inner loop. The returned fit is the input with
sir_ess, sir_ci_theta, sir_ci_omega, sir_ci_sigma (and, when
sir_keep_samples = TRUE, sir_resamples / sir_resamples_n /
sir_resamples_dim) populated.
ferx_fit() records the model and data file paths plus SHA-256 hashes
on the returned fit (fit$model_path, fit$data_path,
fit$model_hash, fit$data_hash). ferx_sir() re-reads those files
and verifies the hashes; if either file changed since the fit, the call
is a hard error. The point of running SIR against the original fit
is to refine its uncertainty estimate, which is meaningless against a
modified model or dataset.
Edge case: if hashing failed at fit time (e.g. permission flip between
parse and hash) the corresponding fit$*_hash is NA and the
integrity check silently passes on that side. This is rare in
practice — hashing would have to fail while the parse just
succeeded — but if you require integrity verification, check
!is.na(fit$model_hash) && !is.na(fit$data_hash) before relying on
the protection.
ferx_fit() for the inline SIR option (sir = TRUE),
ferx_simulate_with_uncertainty() for downstream consumption of the
retained resamples.
if (FALSE) { # \dontrun{
ex <- ferx_example("warfarin")
fit <- ferx_fit(ex$model, ex$data, covariance = TRUE)
fit <- ferx_sir(fit, sir_samples = 2000, sir_resamples = 500, sir_seed = 42)
fit$sir_ess
fit$sir_ci_theta
} # }