Skip to main content

AloInput

Struct AloInput 

Source
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: f64

Dispersion 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>

Source

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 AloInput::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> 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> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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> IntoComptime for T

Source§

fn comptime(self) -> Self

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<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 = !

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

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more