Skip to main content

AloInput

Struct AloInput 

Source
pub struct AloInput<'a> {
    pub design: &'a Array2<f64>,
    pub penalized_hessian: &'a Array2<f64>,
    pub hessian_weights: SignedWeightsView<'a>,
    pub score_weights: PsdWeightsView<'a>,
    pub working_response: &'a Array1<f64>,
    pub eta: &'a Array1<f64>,
    pub offset: &'a Array1<f64>,
    pub link: LinkFunction,
    pub phi: f64,
    pub penalty_root: Option<&'a Array2<f64>>,
    pub ridge: f64,
    pub score_curvature: Option<&'a AloScalarScoreCurvature<'a>>,
}
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 Array2<f64>

Dense design matrix X (n × p).

§penalized_hessian: &'a Array2<f64>

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 Array1<f64>

IRLS working response at convergence (n).

§eta: &'a Array1<f64>

Fitted linear predictor η̂ (n).

§offset: &'a Array1<f64>

Offset vector (n). Pass zeros if no offset.

§link: LinkFunction

Link function (for phi determination).

§phi: f64

Dispersion parameter φ. For non-Gaussian families this is 1.0.

§penalty_root: Option<&'a Array2<f64>>

Optional penalty square root E with E^T E = S(λ) (rank × p) for sandwich SE. When None, sandwich SE is set equal to Bayesian SE.

§ridge: f64

Ridge added to the Hessian for logdet surface.

§score_curvature: Option<&'a AloScalarScoreCurvature<'a>>

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>

Source

pub fn from_geometry( geom: &'a FitGeometry, design: &'a Array2<f64>, eta: &'a Array1<f64>, offset: &'a Array1<f64>, link: LinkFunction, phi: f64, ) -> Self

Build an AloInput from FitGeometry and associated vectors.

Source

pub fn from_geometry_with_working_state( geom: &'a FitGeometry, design: &'a Array2<f64>, eta: &'a Array1<f64>, offset: &'a Array1<f64>, link: LinkFunction, phi: f64, working_weights: &'a Array1<f64>, working_response: &'a Array1<f64>, ) -> Self

Build an AloInput from a FitGeometry’s 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 size-compacted saved model keeps the p×p penalized_hessian (n-independent) but drops those n-sized vectors; a post-fit consumer such as gam diagnose reconstructs them from the saved β by replaying the same PIRLS working-state update the fit used, then feeds them here. This preserves the size win of dropping the working vectors from persistence while still serving the exact geometry ALO path (no refit, exact saved Hessian).

Same canonical (Fisher == Observed) contract as from_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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ByRef<T> for T

Source§

fn by_ref(&self) -> &T

Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> DistributionExt for T
where T: ?Sized,

Source§

fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> T
where Self: Distribution<T>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Imply<T> for U
where T: ?Sized, U: ?Sized,

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts 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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts 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 more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V