Skip to main content

Statistic

Enum Statistic 

Source
pub enum Statistic {
    Pacf,
    LongArYw,
    LongArOls,
    Acf,
    AcfBartlett,
    InversePacf,
    JirakBand,
    PacfRobust,
    AcfRobust,
}
Expand description

Which partial description Σ̂ of the process to threshold.

Variants§

§

Pacf

Partial autocorrelation (AR order). Self-studentized: se = 1/sqrt(n) for lags beyond the true order, whatever the process (Quenouille 1949). Recommended for AR.

§

LongArYw

Coefficients of the Yule–Walker long AR(p_n) with se = 1/sqrt(n) — the literal Fine–Hwang 1979 statistic. Scale-dependent; kept for benchmarking.

§

LongArOls

Coefficients of the OLS long AR(p_n) with classical standard errors. Scale-free.

§

Acf

Autocorrelation with se = 1/sqrt(n) (literal Fine–Hwang MA statistic, §V-D). Scale-dependent.

§

AcfBartlett

Autocorrelation studentized by Bartlett’s formula (MA order). Recommended for MA.

§

InversePacf

Inverse PACF (MA order): PACF of the inverse process, computed from the inverse autocovariances of the long Yule–Walker AR(p_n) fit (the autoregressive estimator of Cleveland 1972; the statistic itself is Bhansali 1983, J. Multivariate Anal. 13 — this is exactly his estimator). An MA(q) process has inverse PACF zero beyond q (his Theorem 3.1), and his Theorem 4.2 gives the exact published null: beyond q the estimates are asymptotically iid N(0, 1/n) and independent of the earlier lags, so se = 1/sqrt(n) is the exact studentisation (conditions: iid innovations with finite fourth moment, invertibility, and a long-AR window growing at least like a multiple of log n but with p_n³/n → 0 — the defaults qualify).

§

JirakBand

Yule–Walker long-AR coefficients with the exact null studentization of Jirak (2012, Thm 2.2): se_i = sqrt(γ̂*_ii · σ̂²(p_n) / n) where γ̂*_ii is the diagonal of the inverse of the estimated autocovariance matrix Γ̂_{p_n} and σ̂²(p_n) the Yule–Walker innovation variance, so each values[i]/se[i] is asymptotically standard normal under the null. Paired with Threshold::Gumbel this is Jirak’s practically recommended band (his Remark 2.6 calibrates the threshold by the max of p_n i.i.d. |N(0,1)|, which is exactly that rule); with alpha_n → 0 it is his consistent estimator q̂⁽¹⁾. Upgrades Statistic::LongArYw, whose 1/sqrt(n) ignores the correlation structure.

§

PacfRobust

Experimental. PACF computed from the Q_n-based robust autocorrelations of Ma & Genton (2000) (the bounded ratio form, whose shared denominator cancels the additive-outlier bias), with the PSD shrinking repair as a safety net (crate::robust). 25 % breakdown point against additive outliers, where the ordinary PACF has none.

Unlike the classical PACF this statistic is not self-studentized: its null dispersion grows with the serial dependence of the process (measured by simulation: ≈1.1/√n on white noise, ≈2.0/√n on a strongly correlated AR(2), ≈2.4/√n on an MA(2)). se = 2.0/sqrt(n) is a conservative empirical compromise pending exact theory, and the default memory is the short poly-log window (per-lag estimation errors are independent across lags, so long memories break positive definiteness).

§

AcfRobust

Experimental. Robust autocorrelation (the Ma & Genton 2000 bounded Q_n-ratio form, crate::robust::robust_autocorrelation) studentized by Bartlett’s formula computed from the robust ACF itself, inflated by 1.15. Monte Carlo calibration (white noise, MA(1), MA(2), AR(2); n = 500–8000; 400 reps) puts the null sd of ρ̂_rob(k) / se_Bartlett(ρ̂_rob) at 1.05–1.12 across all designs, so unlike Statistic::PacfRobust the plug-in pivot is nearly process-independent and 1.15 is a mild safety margin, pending exact theory (the asymptotic variance of the ratio estimator differs from the classical ACF’s; Lévy-Leduc et al. 2011 give it for Gaussian long-memory processes). Targets MA order with a 25 % breakdown point against additive outliers, where Statistic::AcfBartlett has none.

Implementations§

Source§

impl Statistic

Source

pub const ALL: [Statistic; 9]

Source

pub fn name(self) -> &'static str

Examples found in repository?
examples/review_check.rs (line 37)
18fn main() {
19    let mut r = Rng(3);
20    let wn: Vec<f64> = (0..2000).map(|_| r.n()).collect();
21    let shifted: Vec<f64> = wn.iter().map(|v| v + 50.0).collect();
22    for (name, x) in [("ruido branco", &wn), ("ruido branco + 50", &shifted)] {
23        for s in [
24            Statistic::Pacf,
25            Statistic::LongArOls,
26            Statistic::LongArYw,
27            Statistic::AcfBartlett,
28        ] {
29            let f = fh_order(
30                x,
31                FhConfig {
32                    statistic: s,
33                    ..Default::default()
34                },
35            )
36            .unwrap();
37            println!("{name:18} {:14} -> ordem {}", s.name(), f.order);
38        }
39    }
40    let f = fh_order(
41        &wn,
42        FhConfig {
43            threshold: Threshold::BicLike { c: -1.0 },
44            ..Default::default()
45        },
46    )
47    .unwrap();
48    println!("c=-1: ordem {} tau {}", f.order, f.tau);
49    let f = fh_order(
50        &wn,
51        FhConfig {
52            threshold: Threshold::Fixed(-5.0),
53            ..Default::default()
54        },
55    )
56    .unwrap();
57    println!("fixed(-5): ordem {} tau {}", f.order, f.tau);
58    // Hwang condition p_n/(n eta^2) with eta = tau/sqrt(n)
59    for n in [100usize, 1000, 10000, 100000] {
60        let p = power_memory(n);
61        let tau = Threshold::default().value(n, p);
62        println!(
63            "n={n} p_n={p} tau={tau:.2}  p_n/(n eta^2)=p_n/tau^2={:.2}",
64            p as f64 / (tau * tau)
65        );
66    }
67}
Source

pub fn default_memory(self, n: usize) -> usize

Default growing memory p_n used when FhConfig::memory is None: the poly-log window ⌈2 log n⌉ (polylog_memory), which dominated the power rules in the benchmark (it reaches a seasonal AR(12) from n = 400, where ⌊n^0.4⌋ cannot) and is the window covered by the uniform LIL bounds for autocovariances. Statistic::PacfRobust uses the shorter ⌈log n⌉ (its per-lag estimation errors are nearly independent across lags, so long memories drift out of positive definiteness and the deep PACF path turns into boundary noise).

Source

pub fn target(self) -> &'static str

Which model family’s order this statistic targets.

Source

pub fn compute(self, x: &[f64], p_n: usize) -> Result<(Vec<f64>, Vec<f64>)>

Compute (values, se) for lags 1..=p_n.

Trait Implementations§

Source§

impl Clone for Statistic

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for Statistic

Source§

impl Debug for Statistic

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Statistic

Source§

impl Hash for Statistic

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Statistic

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Statistic

Auto Trait Implementations§

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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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, !>

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.