pub struct UnifiedFitResult {Show 29 fields
pub blocks: Vec<FittedBlock>,
pub log_lambdas: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pub lambdas: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pub likelihood_family: Option<LikelihoodSpec>,
pub likelihood_scale: LikelihoodScaleMetadata,
pub log_likelihood_normalization: LogLikelihoodNormalization,
pub log_likelihood: f64,
pub deviance: f64,
pub reml_score: f64,
pub stable_penalty_term: f64,
pub penalized_objective: f64,
pub used_device: bool,
pub outer_iterations: usize,
pub outer_converged: bool,
pub outer_gradient_norm: Option<f64>,
pub standard_deviation: f64,
pub covariance_conditional: Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>,
pub covariance_corrected: Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>,
pub inference: Option<FitInference>,
pub fitted_link: FittedLinkState,
pub geometry: Option<FitGeometry>,
pub block_states: Vec<ParameterBlockState>,
pub beta: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pub pirls_status: PirlsStatus,
pub max_abs_eta: f64,
pub constraint_kkt: Option<ConstraintKktDiagnostics>,
pub artifacts: FitArtifacts,
pub inner_cycles: usize,
pub outer_cost_evals: usize,
}Expand description
Unified fit result for all model types (standard GAM, GAMLSS, survival).
Standard models have a single block; GAMLSS and survival models have multiple blocks with different roles.
Fields§
§blocks: Vec<FittedBlock>Coefficient blocks (1 for standard GAM, N for GAMLSS/survival).
log_lambdas: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>Log-smoothing parameters (all blocks concatenated in block order).
lambdas: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>Smoothing parameters (exp of log_lambdas).
likelihood_family: Option<LikelihoodSpec>Explicit engine-level family, when the fit uses a built-in family.
likelihood_scale: LikelihoodScaleMetadataFixed-scale metadata for the fitted likelihood.
log_likelihood_normalization: LogLikelihoodNormalizationWhether log_likelihood includes response-only normalization constants.
log_likelihood: f64Log-likelihood at the converged mode.
deviance: f64Explicit deviance reported by the fitting path.
reml_score: f64Complete REML/LAML objective value used for smoothing selection.
stable_penalty_term: f64Stable quadratic penalty term βᵀSβ, including any solver ridge quadratic.
penalized_objective: f64Public objective value reported for the fit. For REML/LAML fits this is
the same complete objective as reml_score, not -ℓ + penalty + reml_score.
used_device: boolWhether the converged fit used a GPU execution path for its final inner solve.
outer_iterations: usizeNumber of outer (smoothing parameter) iterations.
outer_converged: boolWhether the outer optimization converged.
outer_gradient_norm: Option<f64>Final gradient norm of the outer optimization. None when no
gradient was measured at termination — cache-hit short-circuit
(the prior fit’s converged ρ was loaded from disk), gradient-free
solver, or a degenerate early-exit path where no outer ran.
outer_converged is the authoritative convergence signal.
standard_deviation: f64Residual scale on the response scale.
Contract: Gaussian identity models store residual standard deviation sigma here. Non-Gaussian families keep the response-scale summary used by their explicit likelihood-scale metadata.
covariance_conditional: Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>Vb: Bayesian/conditional covariance Var(β | λ) = H⁻¹ * φ̂ for the joint coefficient vector.
covariance_corrected: Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>Vp: Bayesian covariance with smoothing-parameter uncertainty correction.
inference: Option<FitInference>Inference quantities from the inner solver (EDF, Hessian, etc.).
fitted_link: FittedLinkStateFitted link parameters (SAS, BetaLogistic, Mixture).
geometry: Option<FitGeometry>Working-set geometry at convergence (for ALO diagnostics and saved-model covariance reconstruction).
block_states: Vec<ParameterBlockState>Internal block states from custom-family paths.
beta: ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>Joint coefficient vector (first block for standard GAMs, concatenated for multi-block).
pirls_status: PirlsStatusInner solver convergence status. Required at decode time: a missing
field on an older-schema or corrupted saved model previously decoded
as Converged via a default, silently promoting non-converged β̂
through warm-start propagation, predict-time confidence intervals,
and outer-loop convergence semantics. With the MODEL_PAYLOAD_VERSION
gate in place, older schemas are rejected before this field is read,
so requiring the field here is safe and strictly removes the silent
default.
max_abs_eta: f64Maximum absolute linear predictor value at convergence.
constraint_kkt: Option<ConstraintKktDiagnostics>Constraint KKT diagnostics (monotone-constrained fits).
artifacts: FitArtifactsSolver artifacts (e.g. cached PIRLS result for ALO).
inner_cycles: usizeInner cycle count (blockwise path).
outer_cost_evals: usizeNumber of outer REML cost-only evaluations the fit executed (each trust-region / line-search probe drives one, paying an inner P-IRLS solve). Diagnostic only — guards regressions in outer work (#1575) and is not part of the statistical contract. Zero for paths that do not run the standard external REML optimizer.
Implementations§
Source§impl UnifiedFitResult
impl UnifiedFitResult
pub fn try_from_parts( parts: UnifiedFitResultParts, ) -> Result<UnifiedFitResult, EstimationError>
pub fn validate_numeric_finiteness(&self) -> Result<(), EstimationError>
Source§impl UnifiedFitResult
impl UnifiedFitResult
pub fn new_for_test_unchecked(parts: UnifiedFitResultParts) -> UnifiedFitResult
Source§impl UnifiedFitResult
impl UnifiedFitResult
Sourcepub fn beta_covariance(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn beta_covariance( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
Get the conditional Bayesian covariance matrix (Vb) if available.
Contract: Vb = H^{-1} * phi, scaled by the fitted dispersion. This is
the Wood/mgcv Vb (Bayesian/conditional) covariance.
Sourcepub fn beta_covariance_ve(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn beta_covariance_ve( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
Get the frequentist sandwich covariance (Ve) if available.
Wood/mgcv Ve = H⁻¹ X'WX H⁻¹ * φ̂.
Sourcepub fn coefficient_influence(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn coefficient_influence( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
Get coefficient-space influence matrix F = H^{-1}X'WX if available.
Sourcepub fn weighted_gram(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn weighted_gram( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
Get the original-basis weighted Gram X'WX = H − S(λ) if available —
the symmetric PSD matrix the Wood–Pya–Säfken corrected-EDF correction
pairs with the smoothing-parameter uncertainty covariance (issue #1027).
Sourcepub fn dispersion(&self) -> Option<Dispersion>
pub fn dispersion(&self) -> Option<Dispersion>
Dispersion used to scale covariance matrices.
Sourcepub fn dispersion_phi(&self) -> f64
pub fn dispersion_phi(&self) -> f64
Canonical residual dispersion φ̂ — the response-level observation noise
(Gaussian σ̂², Gamma 1/shape, Beta 1/(1+φ), fixed-scale families
1). This is the predictive observation-noise scale used to widen
prediction observation intervals; it is NOT the coefficient-covariance
scale (see Self::coefficient_covariance_scale). For families whose
IRLS working weight already carries 1/φ, the two differ: the
coefficient covariance is H⁻¹ (scale 1) while this dispersion stays
1/shape (#679).
Unlike Self::dispersion, which reads the cached inference block,
this is computed from fields that always survive serialization
(likelihood_family, likelihood_scale, standard_deviation). That
matters for deployment-time consumers operating on a saved model whose
inference block was dropped (e.g. core_saved_fit_result stores
inference: None): the cached dispersion() is then None, but the
scale is still recoverable and identical to the value used at fit time.
When the cached block is present its dispersion is preferred verbatim so
the two paths never diverge.
Sourcepub fn coefficient_covariance_scale(&self) -> f64
pub fn coefficient_covariance_scale(&self) -> f64
Multiplier that turns the stored unscaled inverse penalized Hessian
H⁻¹ into the reported coefficient covariance Vb = H⁻¹·scale.
This is the deployment-time / serialized-model counterpart of
GlmLikelihoodSpec::coefficient_covariance_scale, used wherever the full
stored beta_covariance() is unavailable and Vb must be reconstructed
from the factorized Hessian (large-model predict path). It returns the
profiled residual variance σ̂² for the scale-free profiled Gaussian and
1.0 for every family whose IRLS working weight already carries the
dispersion / full Fisher information (Gamma, Tweedie, Beta,
Negative-Binomial, Poisson, Binomial) — see #679. For custom/GAMLSS
paths with no engine-level family it falls back to 1.0.
Sourcepub fn beta_covariance_corrected(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn beta_covariance_corrected( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
Get the smoothing-parameter-corrected beta covariance (Vp) if available.
Wood/mgcv name for the smoothing-parameter-corrected covariance Vp.
Sourcepub fn beta_standard_errors(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
pub fn beta_standard_errors( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
Get beta standard errors (conditional) if available.
Sourcepub fn beta_standard_errors_corrected(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
pub fn beta_standard_errors_corrected( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
Get smoothing-corrected beta standard errors if available.
Sourcepub fn bias_correction_beta(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
pub fn bias_correction_beta( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
Get the O(n⁻¹) bias-correction vector b̂ = H⁻¹ S(λ̂) β̂ in the original coefficient basis, if available.
Sourcepub fn penalized_hessian(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn penalized_hessian( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
Get the penalized Hessian if available.
Boundary accessor: returns &Array2<f64> so out-of-scope consumers
(CLI, GPU, families) keep their pre-newtype call shape. Use
Self::penalized_hessian_unscaled when the caller wants the
[UnscaledPrecision] newtype to enforce the dispersion-ownership
invariant.
Sourcepub fn penalized_hessian_unscaled(&self) -> Option<&UnscaledPrecision>
pub fn penalized_hessian_unscaled(&self) -> Option<&UnscaledPrecision>
Get the penalized Hessian as the [UnscaledPrecision] newtype if
available. Use this when constructing newtype-aware APIs (HMC
whitening, sampling) so the dispersion convention is enforced at
the type level.
Sourcepub fn beta_covariance_phi_scaled(&self) -> Option<&PhiScaledCovariance>
pub fn beta_covariance_phi_scaled(&self) -> Option<&PhiScaledCovariance>
Get the φ-scaled posterior covariance as the [PhiScaledCovariance]
newtype if available, sourced from FitInference::beta_covariance.
Prefer this over Self::beta_covariance in inference-internal
code so the φ-scaled invariant is type-enforced.
Sourcepub fn working_weights(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
pub fn working_weights( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
Get working weights if available.
Sourcepub fn working_response(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
pub fn working_response( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
Get working response if available.
Sourcepub fn smoothing_correction(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn smoothing_correction( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
Smoothing-parameter uncertainty covariance contribution J·Var(ρ)·Jᵀ
in coefficient space, on the same dispersion scale as the conditional
covariance Vb = φ·H⁻¹. This is the exact ρ-uncertainty term assembled
from the IFT dβ̂/dρ and the outer Hessian at the fit optimum; the
model-comparison machinery divides it by φ to recover the H⁻¹-scale
ρ-covariance needed for the Wood–Pya–Säfken corrected EDF.
Sourcepub fn edf_by_block(&self) -> &[f64]
pub fn edf_by_block(&self) -> &[f64]
EDF by block.
Sourcepub fn penalty_block_trace(&self) -> &[f64]
pub fn penalty_block_trace(&self) -> &[f64]
Raw per-penalty-block trace tr_kk = λ_kk·tr(H⁻¹ S_kk), aligned 1:1 with
lambdas. Empty when the producing path did not record traces (issue
#1219); callers must treat an empty slice as “unavailable”.
Sourcepub fn per_term_edf(
&self,
coeff_range: Range<usize>,
penalty_cursor: usize,
k: usize,
) -> f64
pub fn per_term_edf( &self, coeff_range: Range<usize>, penalty_cursor: usize, k: usize, ) -> f64
Per-term effective degrees of freedom over a smooth/random-effect term’s
coefficient block, defined as the trace of the linear-smoother influence
matrix F = H⁻¹X'WX restricted to that block:
edf_term = Σ_{j ∈ coeff_range} F[j,j]
= |coeff_range| − Σ_{kk ∈ term} tr_kk, tr_kk = λ_kk·tr(H⁻¹ S_kk).This is additive across terms and sums exactly to edf_total = p − Σ_all tr_kk, so a term’s EDF can never exceed the model total or the design
column count. The legacy per-block EDF sum Σ_kk (rank(S_kk) − tr_kk)
double-counts shared tensor coefficients for te/ti (and anisotropic /
adaptive) smooths, where several penalty blocks span the same coefficient
range and Σ_kk rank(S_kk) ≫ |coeff_range| (#1219, #1277).
penalty_cursor is the index of the term’s first penalty block in the
flat lambdas / penalty_block_trace / edf_by_block layout, and k is
the number of penalty blocks the term owns (0 for an unpenalised term).
Resolution order, each exact when available: the influence-matrix trace
(the model’s own definition), then |coeff_range| − Σ tr_kk from the
stored per-block traces (basis-invariant; exact even when F was never
materialised for a large model), then — only when neither was recorded —
the legacy block-sum as a last resort.
Sourcepub fn block_by_role(&self, role: BlockRole) -> Option<&FittedBlock>
pub fn block_by_role(&self, role: BlockRole) -> Option<&FittedBlock>
Find a block by role.
Sourcepub fn beta_flat(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn beta_flat(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Flat coefficient vector (all blocks concatenated).
This is equivalent to self.beta.clone().
Sourcepub fn beta_time(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn beta_time(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Time/baseline-hazard coefficients (survival location-scale).
Sourcepub fn beta_threshold(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn beta_threshold(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Threshold coefficients (survival location-scale).
Sourcepub fn beta_log_sigma(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn beta_log_sigma(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Log-sigma coefficients (survival location-scale).
Sourcepub fn beta_link_wiggle(
&self,
) -> Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
pub fn beta_link_wiggle( &self, ) -> Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
Link-wiggle coefficients (survival location-scale, optional).
Sourcepub fn lambdas_time(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn lambdas_time(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Smoothing parameters for time block.
Sourcepub fn lambdas_threshold(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn lambdas_threshold(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Smoothing parameters for threshold block.
Sourcepub fn lambdas_log_sigma(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
pub fn lambdas_log_sigma(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>
Smoothing parameters for log-sigma block.
Sourcepub fn lambdas_linkwiggle(
&self,
) -> Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
pub fn lambdas_linkwiggle( &self, ) -> Option<ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>>
Smoothing parameters for link-wiggle block.
Sourcepub fn block_roles(&self) -> Vec<BlockRole>
pub fn block_roles(&self) -> Vec<BlockRole>
Block roles.
Sourcepub fn fitted_link_state(
&self,
family: &LikelihoodSpec,
) -> Result<FittedLinkState, EstimationError>
pub fn fitted_link_state( &self, family: &LikelihoodSpec, ) -> Result<FittedLinkState, EstimationError>
Resolve the fitted link state for a given family.
For standard (non-adaptive) link families, no extra state is fitted, so
this returns the bare FittedLinkState::Standard(None) payload — the
concrete LinkFunction lives on the family/spec and is not duplicated
into the fitted-link record. For adaptive links (SAS, BetaLogistic,
Mixture, LatentCLogLog) it validates that the stored state matches the
family and clones it out.
Trait Implementations§
Source§impl Clone for UnifiedFitResult
impl Clone for UnifiedFitResult
Source§fn clone(&self) -> UnifiedFitResult
fn clone(&self) -> UnifiedFitResult
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for UnifiedFitResult
impl Debug for UnifiedFitResult
Source§impl<'de> Deserialize<'de> for UnifiedFitResult
impl<'de> Deserialize<'de> for UnifiedFitResult
Source§fn deserialize<__D>(
__deserializer: __D,
) -> Result<UnifiedFitResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(
__deserializer: __D,
) -> Result<UnifiedFitResult, <__D as Deserializer<'de>>::Error>where
__D: Deserializer<'de>,
Source§impl Serialize for UnifiedFitResult
impl Serialize for UnifiedFitResult
Source§fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
fn serialize<__S>(
&self,
__serializer: __S,
) -> Result<<__S as Serializer>::Ok, <__S as Serializer>::Error>where
__S: Serializer,
Auto Trait Implementations§
impl !RefUnwindSafe for UnifiedFitResult
impl !UnwindSafe for UnifiedFitResult
impl Freeze for UnifiedFitResult
impl Send for UnifiedFitResult
impl Sync for UnifiedFitResult
impl Unpin for UnifiedFitResult
impl UnsafeUnpin for UnifiedFitResult
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.