pub struct AloInput<'a> {
pub design: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>,
pub penalized_hessian: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>,
pub hessian_weights: SignedWeightsView<'a>,
pub score_weights: PsdWeightsView<'a>,
pub working_response: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pub eta: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pub offset: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
pub phi: f64,
pub score_curvature: Option<&'a (dyn Fn(usize, f64) -> Result<(f64, f64), AloError> + Sync)>,
}Expand description
Model-agnostic input for ALO diagnostics.
Any model with a design matrix, penalized Hessian, and IRLS geometry can compute ALO leverages and leave-one-out predictions. This decouples ALO from the single-block PIRLS solver and enables diagnostics for GAMLSS, survival, and joint models.
Fields§
§design: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>Dense design matrix X (n × p).
penalized_hessian: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>Penalized Hessian H = X’WX + S(λ) at convergence (p × p).
hessian_weights: SignedWeightsView<'a>Hessian-side IRLS weights W_H at convergence (n). Sign-honest: for
non-canonical links the observed-information diagonal can have negative
entries, so the typed SignedWeightsView is the contract here. PSD
callers needing to promote (e.g. the canonical-link case where the
caller has discharged W_H ≥ 0 algebraically) can route through
SignedWeightsView::as_psd() at the consumer.
score_weights: PsdWeightsView<'a>Score-side IRLS weights W_S paired with working_response (n).
PSD-by-construction: the score-side Fisher weights h'²/(φ V(μ)) ≥ 0.
working_response: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>IRLS working response at convergence (n).
eta: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>Fitted linear predictor η̂ (n).
offset: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>Offset vector (n). Pass zeros if no offset.
phi: f64Dispersion parameter φ. For non-Gaussian families this is 1.0.
score_curvature: Option<&'a (dyn Fn(usize, f64) -> Result<(f64, f64), AloError> + Sync)>Optional per-row score/curvature evaluator (i, η) → (ℓ_i'(η), ℓ_i''(η)).
When supplied, the leave-i-out predictor is obtained by solving the
frozen-curvature scalar fixed point η = η̂_i + a_ii ℓ_i'(η) to
convergence (see [alo_eta_exact_frozen_curvature]) instead of taking a
single Newton step. This eliminates the first-order linearization error
that the one-step ALO incurs on small-n, strongly curved likelihoods
(e.g. binomial logistic regression). Non-convergence or invalid scalar
Newton geometry is returned as an ALO error. When None, the classical
single-Newton-step ALO formula is used. The evaluator must be consistent
with hessian_weights at convergence: ℓ_i''(η̂_i) = W_H[i] and
ℓ_i'(η̂_i) = W_S[i]·((η̂_i−o_i) − (z_i−o_i)).
Implementations§
Source§impl<'a> AloInput<'a>
impl<'a> AloInput<'a>
Sourcepub fn from_penalized_hessian_with_working_state(
penalized_hessian: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>,
design: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>,
eta: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
offset: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
phi: f64,
working_weights: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
working_response: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>,
) -> AloInput<'a>
pub fn from_penalized_hessian_with_working_state( penalized_hessian: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, design: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, eta: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, offset: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, phi: f64, working_weights: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, working_response: &'a ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, ) -> AloInput<'a>
Build an AloInput from an exact saved penalized Hessian plus externally
supplied working weights / working response.
The row-sized IRLS working vectors are derived quantities: at
convergence they are deterministic functions of the linear predictor
η̂ = Xβ̂, the response y, and the family (w_i = h'(η̂_i)²/(φ V(μ̂_i))· prior_i, z_i = η̂_i + (y_i−μ̂_i)/h'(η̂_i)). A saved-model consumer
reconstructs them from the saved β by replaying the same PIRLS
working-state update the fit used, then feeds them here. The precision
comes from the canonical fit’s exact unscaled Hessian accessor; callers
do not need a second FitGeometry wrapper or a covariance inversion.
Same canonical (Fisher == Observed) contract as
from_active_geometry: the
supplied working_weights are the score-side Fisher weights and are
re-viewed for the Hessian-side slot via as_signed().
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for AloInput<'a>
impl<'a> !UnwindSafe for AloInput<'a>
impl<'a> Freeze for AloInput<'a>
impl<'a> Send for AloInput<'a>
impl<'a> Sync for AloInput<'a>
impl<'a> Unpin for AloInput<'a>
impl<'a> UnsafeUnpin for AloInput<'a>
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> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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.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.