Skip to main content

Module robust

Module robust 

Source
Expand description

Robust scale and autocovariance estimation.

  • qn — the Q_n scale estimator of Rousseeuw & Croux (1993), computed by the O(n log n) algorithm of Croux & Rousseeuw (1992). Conventions (consistency constant and finite-sample corrections) follow R’s robustbase::Qn, so the two agree to full double precision; note the published papers print the constant as 2.2219, a digit transposition of the correct 1/(sqrt(2) Φ⁻¹(5/8)) = 2.21914… (Ma & Genton 2000 print 2.2191).
  • robust_autocovariance — the Q_n-based autocovariance of Ma & Genton (2000, eq. 4): γ̂_Q(h) = ¼ [Q²_{n−h}(u+v) − Q²_{n−h}(u−v)] with u = (X_1..X_{n−h}), v = (X_{h+1}..X_n). Breakdown point 25 %, the maximum possible for an autocovariance estimator.
  • shrink_to_psd — γ̂_Q is not guaranteed positive semi-definite; this applies the shrinking repair (Rousseeuw & Molenberghs 1993): scale the off-diagonal lags by the largest 1−λ that makes the Toeplitz matrix PSD (checked by Cholesky, found by bisection). λ = 0 on clean data.

Functions§

qn
Q_n scale estimator with Gaussian consistency constant and the finite-sample corrections used by robustbase::Qn (Croux & Rousseeuw 1992, updated constants). Q_n = d_n · 2.21914 · {|x_i − x_j|; i<j}_(k) with k = C(h,2), h = ⌊n/2⌋+1. Returns 0 for n < 2.
robust_autocorrelation
Ma & Genton’s (2000) robust autocorrelations for lags 0..=max_lag: ρ̂_Q(h) = [Q²(u+v) − Q²(u−v)] / [Q²(u+v) + Q²(u−v)], bounded in [−1, 1] by construction and independent of the consistency constant. Numerator and denominator share the same contaminated pairs, so the additive-outlier bias that affects γ̂_Q(h)/γ̂_Q(0) largely cancels (this is what crate::Statistic::PacfRobust feeds into Levinson).
robust_autocovariance
Ma & Genton (2000, eq. 4) Q_n-based autocovariances for lags 0..=max_lag: γ̂_Q(0) = Q²_n(x) and γ̂_Q(h) = ¼ [Q²_{n−h}(u+v) − Q²_{n−h}(u−v)] with u = (X_1..X_{n−h}), v = (X_{h+1}..X_n). Location-invariant and scale- equivariant; 25 % temporal breakdown point. Not guaranteed PSD — pass the result through shrink_to_psd before Levinson/Yule–Walker use.
shrink_to_psd
Shrinking repair for a possibly non-PSD autocovariance sequence (Rousseeuw & Molenberghs 1993): return r' with r'(0) = r(0) and r'(h) = (1−λ) r(h), λ the smallest value in [0, 1] (up to bisection tolerance) such that the Toeplitz matrix of r' stays positive definite with a relative ridge margin of 1e-3 · r(0) — the margin keeps estimated sequences away from the PD boundary, where Levinson would report spurious reflection coefficients near ±1. On a sequence that already satisfies the margin this returns the input unchanged (λ = 0).