pub enum Threshold {
BicLike {
c: f64,
},
Lil {
c: f64,
},
MaxOfK {
c: f64,
},
Fixed(f64),
Gumbel {
alpha: f64,
},
}Expand description
Threshold rule on the studentized scale.
Variants§
BicLike
sqrt(c · log n). With c = 1 this equals the per-increment threshold implicit in BIC
(adjacent-order BIC difference is negative iff t_k² > log n to first order) — this is
not the same as BIC’s global argmin. Requires c > 0.
Lil
sqrt(2 c · log log n): Hannan–Quinn / law-of-the-iterated-logarithm rate. Requires c > 0;
consistency arguments need c > 1.
MaxOfK
sqrt(2 · log p_n) + c: Bonferroni/extreme-value correction for the number of lags
inspected — the natural companion of Jirak’s (2012) Gumbel limit. Requires c ≥ 0.
Fixed(f64)
Fixed value on the studentized scale, e.g. 1.96 reproduces the Box–Jenkins band
(not consistent; for benchmarking). Requires a finite value ≥ 0.
Gumbel
Level-calibrated threshold: the 1−alpha quantile of the Gumbel limit of
max_{k ≤ p_n} |Z_k|, Z_k approximately standard normal, i.e.
b_p + a_p · (−log(−log(1−alpha))) with a_p = 1/sqrt(2 log p) and
b_p = sqrt(2 log p) − (log log p + log π) / (2 sqrt(2 log p)) (absolute values ⇒ 2p tails).
With a fixed alpha this controls the family-wise overestimation probability at ≈ alpha
(not consistent); with alpha = alpha_n → 0 slowly it is the Jirak-type consistent rule
(D-20). Jirak (2012) gives the exact normalising constants for Yule–Walker estimates;
this generic form is a placeholder until Statistic::JirakBand lands (PLAN M1).
Requires 0 < alpha < 1.
Implementations§
Source§impl Threshold
impl Threshold
Sourcepub fn validate(self) -> Result<()>
pub fn validate(self) -> Result<()>
Reject parameters that would make the rule meaningless (negative or NaN constants).
Sourcepub fn value(self, n: usize, p_n: usize) -> f64
pub fn value(self, n: usize, p_n: usize) -> f64
Numerical threshold for sample size n and memory p_n.
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}