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
impl Statistic
pub const ALL: [Statistic; 9]
Sourcepub fn name(self) -> &'static str
pub fn name(self) -> &'static str
Examples found in repository?
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}Sourcepub fn default_memory(self, n: usize) -> usize
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).