pub struct UnifiedFitResult {Show 26 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 stable_penalty_term: f64,
pub used_device: bool,
pub outer_iterations: usize,
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 max_abs_eta: f64,
pub constraint_kkt: Option<ConstraintKktDiagnostics>,
pub artifacts: FitArtifacts,
pub inner_cycles: usize,
pub outer_cost_evals: usize,
pub inner_pirls_solves: usize,
/* private fields */
}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.
stable_penalty_term: f64Stable quadratic penalty term βᵀSβ, including any solver ridge quadratic.
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_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.
Fit existence 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).
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.
inner_pirls_solves: usizeNumber of actual full-n inner P-IRLS solves the fit performed (the
cache-missing solves across the seed-grid prepass, screening, multistart,
and finalize). This is the true #1575 cost metric — distinct from, and
typically ~2× larger than, outer_cost_evals, which counts outer
requests including single-slot cache hits. Diagnostic only; not part of
the statistical contract. Zero for paths that do not run the standard
external REML optimizer.
Implementations§
Source§impl UnifiedFitResult
impl UnifiedFitResult
Sourcepub fn convergence_evidence(&self) -> &FitConvergenceEvidence
pub fn convergence_evidence(&self) -> &FitConvergenceEvidence
Proof carried by every fitted model. Callers never need to re-check a convergence boolean; construction has already consumed and validated the inner and outer evidence.
Sourcepub fn training_sample_size(&self) -> usize
pub fn training_sample_size(&self) -> usize
Number of original training rows / experimental units.
Sourcepub fn reml_score(&self) -> Option<f64>
pub fn reml_score(&self) -> Option<f64>
The fit’s REML/LAML criterion, or None when no finite criterion exists
at this fit.
None is not “unavailable”; it is the statement that the criterion is
unbounded — see the field documentation. Callers that rank, compare, or
normalize must propagate the absence, not substitute a number for it —
NO_CRITERION_AT_EXACT_FIT is the one explanation to refuse with.
The answer is decided by Self::at_zero_dispersion_boundary and not
by the stored number alone. Payloads written before the criterion could
be absent carry 0.0 at that boundary — the placeholder, not a
criterion — so a legacy model loaded from disk gets the same honest
answer as a fresh fit, without a migration pass over saved artifacts.
Sourcepub fn at_zero_dispersion_boundary(&self) -> bool
pub fn at_zero_dispersion_boundary(&self) -> bool
true at the exact-fit Gaussian boundary: a profiled Gaussian scale
estimated as exactly zero.
This is the single state in which a fit has neither a normalized
Lebesgue density nor a REML/LAML criterion — the fitted mean reproduces
the response, so φ̂ = 0 and both the full likelihood and the restricted
likelihood are unbounded. It is DERIVED from the fit’s own persisted
family, scale metadata and σ̂, so a model loaded from disk reaches the
same verdict as the live one, and no separate flag can drift from it.
Sourcepub fn reported_log_likelihood(&self) -> Option<f64>
pub fn reported_log_likelihood(&self) -> Option<f64>
The fit’s log-likelihood, or None when the fit declined to claim one.
The decline is the same boundary as the criterion’s: log_likelihood
carries 0.0 under LogLikelihoodNormalization::UserProvided there,
which states that no normalized density exists — a fact a consumer that
reads the bare f64 cannot see. Ranking on that zero is how an
exactly-interpolating fit scores −2·0 + 2·edf in a conditional-AIC
comparison and wins on nothing.
Sourcepub fn penalized_objective(&self) -> Option<f64>
pub fn penalized_objective(&self) -> Option<f64>
Public objective value reported for the fit; absent exactly when
Self::reml_score is absent.
Sourcepub fn set_criterion(&mut self, value: Option<f64>)
pub fn set_criterion(&mut self, value: Option<f64>)
Replace the criterion with the value a later outer solve produced at this same fit.
Sets both faces of the objective at once: the constructor requires them to be present or absent together, and two independent setters would let a caller satisfy one and not the other on an already-built result, where nothing re-validates.
Sourcepub fn shift_criterion(&mut self, delta: f64)
pub fn shift_criterion(&mut self, delta: f64)
Shift the criterion by an additive constant — a response-rescaling Jacobian, a normalizer, any term that moves the objective without re-solving it.
Absent stays absent: a constant added to a criterion that does not exist still does not exist, and silently materializing one here is the exact substitution this type was made optional to prevent.
Sourcepub fn wald_residual_degrees_of_freedom(&self) -> Option<f64>
pub fn wald_residual_degrees_of_freedom(&self) -> Option<f64>
Denominator degrees of freedom for estimated-scale Wald/F references.
Both in-process and persisted-model summaries call this method so the definition cannot drift between presentation surfaces.
Sourcepub fn posterior_moment_decline(&self) -> Option<&ConePosteriorMomentDecline>
pub fn posterior_moment_decline(&self) -> Option<&ConePosteriorMomentDecline>
Typed reason the saved coefficient vector is a constrained optimizer mode rather than the posterior mean required by the public estimand.
Sourcepub fn require_posterior_mean(
&self,
operation: &str,
) -> Result<(), EstimationError>
pub fn require_posterior_mean( &self, operation: &str, ) -> Result<(), EstimationError>
Refuse any operation that would label a constrained mode as a posterior mean. Keeping the converged low-level fit is valid; building a predictive model from an estimand whose moments were declined is not.
pub fn try_from_parts( parts: UnifiedFitResultParts, ) -> Result<UnifiedFitResult, EstimationError>
pub fn validate_numeric_finiteness(&self) -> Result<(), EstimationError>
Source§impl UnifiedFitResult
impl UnifiedFitResult
Sourcepub fn rescale_estimated_dispersion(
&mut self,
var_ratio: f64,
) -> Result<f64, EstimationError>
pub fn rescale_estimated_dispersion( &mut self, var_ratio: f64, ) -> Result<f64, EstimationError>
Rescale every dispersion-linked covariance quantity in place by
var_ratio (equivalently, rescale the estimated dispersion σ̂² by
var_ratio and σ̂ by √var_ratio), keeping the fit’s two redundant
covariance representations bit-for-bit consistent.
A GAM fit stores the conditional/corrected coefficient covariance in TWO
places that Self::validate requires to be identical: the top-level
covariance_conditional / covariance_corrected and the paired
inference.beta_covariance / beta_covariance_corrected. Because
Vb = σ̂²·H⁻¹ (and Vp likewise) is linear in the dispersion, any
post-fit change to σ̂² — e.g. the #1788 EDF-collapse guard re-deriving
σ̂² = RSS/(n − edf_total) from a corrected effective d.f. — must scale
BOTH representations by the same factor, or the model silently fails its
own consistency check on the next validate() and every downstream
consumer (predict/summary/save→load) rejects it (#1789). Routing
each such rescale through this single method makes that impossible to get
wrong: the top-level and inference blocks can never drift apart.
Fixed-scale families are a no-op. Invalid or unrepresentable rescaling
is an error, and every product is preflighted before any field is
mutated, so the redundant covariance representations remain atomic.
Returns the applied standard-deviation ratio (sqrt(var_ratio)), or one
for a fixed scale / an exact unit multiplier.
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) in the saved/raw
coefficient frame, if available.
Contract: for an active geometry gauge β = Tθ + a,
Vb_raw = T H_active^{-1} Tᵀ * phi. For an identity gauge this
reduces to H^{-1} * phi. This is the Wood/mgcv Vb
(Bayesian/conditional) covariance.
§Which of the two published covariances to use
This one treats λ̂ as KNOWN. It is the right object when the
smoothing parameters are fixed by the caller rather than estimated, and
it is the reference against which
Self::beta_covariance_corrected is judged: for a Gaussian identity
fit with W = I the trace identity E_x[xᵀVb x] = φ·edf/n pins its
size exactly, with no Monte Carlo and no truth involved.
It is NOT the same as the frequentist sampling covariance Vf: they
differ by Vb − Vf = φ·H⁻¹SH⁻¹ ⪰ 0, the smoothing bias term, which is
exactly why a Bayesian interval built from Vb attains its nominal
frequentist coverage across the function (Nychka 1988, Marra & Wood
2012) while an interval built from Vf does not.
When λ̂ was ESTIMATED — the default — the interval a user wants is
Self::beta_covariance_corrected, which additionally propagates the
uncertainty in λ̂ itself. predict() defaults to that one.
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) -> Result<f64, EstimationError>
pub fn dispersion_phi(&self) -> Result<f64, EstimationError>
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.
A cached inference dispersion is accepted only when it agrees exactly
with the scale reconstructed from the family contract. Families without
a scalar response scale return an error instead of adopting a fictitious
unit dispersion.
Sourcepub fn coefficient_covariance_scale(&self) -> Result<f64, EstimationError>
pub fn coefficient_covariance_scale(&self) -> Result<f64, EstimationError>
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 is undefined.
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.
When there are no smoothing coordinates, Var(rho) has dimension zero
and the correction J Var(rho) Jᵀ is identically zero. In that exact
case the persisted conditional covariance is already Vp; requiring a
duplicate corrected matrix would make ordinary parametric models lose
posterior-mean intervals after serialization.
§Which of the two published covariances to use
This one, whenever the smoothing parameters were estimated — which
is the default, and what predict() uses. It is
Self::beta_covariance plus the propagated uncertainty in λ̂
itself, by the law of total covariance
Var(β|y) = E_ρ[φ·H(ρ)⁻¹] + Cov_ρ[β̂(ρ)],so it is the wider of the two, and it is the one whose nominal coverage
is honest when λ̂ is itself an estimate. Use
Self::beta_covariance instead only when λ is fixed by the caller,
or when you specifically want the conditional-on-λ̂ object.
How much wider is a property of the fit, not a constant: it is small
where the outer criterion is sharply determined and larger where it is
broad. A gap of ORDERS of magnitude is a defect, not a feature —
SmoothingCorrectionMethod::SigmaPointCubature::max_node_criterion_rise
is the published diagnostic for the one that produced #2728.
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 display_coefficient_uncertainty(
&self,
) -> Option<DisplayCoefficientUncertainty<'_>>
pub fn display_coefficient_uncertainty( &self, ) -> Option<DisplayCoefficientUncertainty<'_>>
Corrected-preferred, definition-consistent coefficient uncertainty for summary/report display surfaces (#2296).
Returns the smoothing-corrected standard errors (with the corrected
covariance, when persisted) if the fit carries them, else the
conditional pair. Standard errors and covariance are NEVER mixed
across definitions: if the preferred definition has SEs but no matrix,
the matrix slot is None rather than a different definition’s matrix.
The returned CoefficientCovarianceDefinition names what was
actually selected so presenters serialize result-owned provenance —
a display policy or request is never evidence of what was used.
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 bias_correction_jacobian(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn bias_correction_jacobian( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
Get the O(n⁻¹) bias-correction Jacobian A = I + H⁻¹ S(λ̂), if available.
Prediction uses it to form the conditional bias-corrected band covariance
A·V·Aᵀ (#1870); None when the full inverse was unavailable.
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.
The matrix is in the active geometry coordinate frame when
Self::geometry is present, so it may be smaller than the saved beta
vector. Pair it with geometry.coefficient_gauge; only an identity gauge
makes this a saved/raw-coordinate Hessian.
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 active-coordinate penalized Hessian as the
UnscaledPrecision newtype if available. Use this when constructing
newtype-aware APIs (HMC whitening, sampling) so both the dispersion
convention and the accompanying geometry.coefficient_gauge are
handled explicitly.
Sourcepub fn working_geometry(&self) -> Option<&WorkingGeometry>
pub fn working_geometry(&self) -> Option<&WorkingGeometry>
Get owned row-wise diagonal working evidence if available.
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 single diagonal row evidence is 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 single diagonal row evidence is 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.
pub fn smoothing_correction_method(&self) -> Option<SmoothingCorrectionMethod>
Sourcepub fn smoothing_correction_first_order(
&self,
) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
pub fn smoothing_correction_first_order( &self, ) -> Option<&ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>>
The exact first-order IFT smoothing-parameter-uncertainty correction,
retained even when Self::smoothing_correction holds a cubature
upgrade instead. This is the accessor the #946 WPS corrected-EDF/AIC
channel must read from: it is populated whenever the first-order
geometry was computable, independent of whether the fit’s PRIMARY
correction escalated to sigma-point cubature for some other consumer.
Sourcepub fn smoothing_correction_method_first_order(
&self,
) -> Option<SmoothingCorrectionMethod>
pub fn smoothing_correction_method_first_order( &self, ) -> Option<SmoothingCorrectionMethod>
Provenance for Self::smoothing_correction_first_order. Always
either None or Some(FirstOrderIdentifiedSubspace{..}).
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.