Skip to main content

sample_saved_model

Function sample_saved_model 

Source
pub fn sample_saved_model(
    model: &FittedModel,
    data: ArrayView2<'_, f64>,
    col_map: &HashMap<String, usize>,
    training_headers: Option<&Vec<String>>,
    cfg: &NutsConfig,
) -> Result<NutsResult, String>
Expand description

Run NUTS posterior sampling over a saved model.

Dispatches on model.predict_model_class():

  • Standard: Gaussian identity models use the exact saved N(mode, φ·H⁻¹) posterior, where mode, φ, and H all come from the training fit. Other standard GLMs run NUTS from the saved mode, smoothing parameters, dispersion, and whitening curvature rather than refitting/reselecting them on the caller-supplied rows. Link-wiggle models take a specialised joint-space path that preserves the basis chain rule.
  • Survival: rebuilds the survival design (Royston-Parmar baseline + wiggle + covariate blocks) on the supplied data, evaluates the mode, and runs the survival-flat NUTS path. Latent and location-scale modes are explicitly rejected here.
  • Other model classes (location-scale GLM, bernoulli marginal-slope, transformation-normal) return a “not implemented” error matching the CLI surface.