solow-var 0.2.0

Vector autoregression (VAR, VECM) for the Solow statistical library
Documentation
//! Tabulated asymptotic critical values for the Johansen cointegration test.
//!
//! The tables are the MacKinnon-Haug-Michelis style quantiles bundled with the
//! reference `tsa.coint_tables` module, indexed by the number of common trends
//! `n = K - i` (1..=12) and the deterministic order `p` (-1, 0, 1). Each row
//! holds the 90%, 95% and 99% quantiles. Values for `n > 12` or unsupported `p`
//! are `NaN`.

/// Maximum-eigenvalue critical values, `p = -1`.
const EJCP0: [[f64; 3]; 12] = [
    [2.9762, 4.1296, 6.9406],
    [9.4748, 11.2246, 15.0923],
    [15.7175, 17.7961, 22.2519],
    [21.837, 24.1592, 29.0609],
    [27.916, 30.4428, 35.7359],
    [33.9271, 36.6301, 42.2333],
    [39.9085, 42.7679, 48.6606],
    [45.893, 48.8795, 55.0335],
    [51.8528, 54.9629, 61.3449],
    [57.7954, 61.0404, 67.6415],
    [63.7248, 67.0756, 73.8856],
    [69.6513, 73.0946, 80.0937],
];

/// Maximum-eigenvalue critical values, `p = 0`.
const EJCP1: [[f64; 3]; 12] = [
    [2.7055, 3.8415, 6.6349],
    [12.2971, 14.2639, 18.52],
    [18.8928, 21.1314, 25.865],
    [25.1236, 27.5858, 32.7172],
    [31.2379, 33.8777, 39.3693],
    [37.2786, 40.0763, 45.8662],
    [43.2947, 46.2299, 52.3069],
    [49.2855, 52.3622, 58.6634],
    [55.2412, 58.4332, 64.996],
    [61.2041, 64.504, 71.2525],
    [67.1307, 70.5392, 77.4877],
    [73.0563, 76.5734, 83.7105],
];

/// Maximum-eigenvalue critical values, `p = 1`.
const EJCP2: [[f64; 3]; 12] = [
    [2.7055, 3.8415, 6.6349],
    [15.0006, 17.1481, 21.7465],
    [21.8731, 24.2522, 29.2631],
    [28.2398, 30.8151, 36.193],
    [34.4202, 37.1646, 42.8612],
    [40.5244, 43.4183, 49.4095],
    [46.5583, 49.5875, 55.8171],
    [52.5858, 55.7302, 62.1741],
    [58.5316, 61.8051, 68.503],
    [64.5292, 67.904, 74.7434],
    [70.463, 73.9355, 81.0678],
    [76.4081, 79.9878, 87.2395],
];

/// Trace critical values, `p = -1`.
const TJCP0: [[f64; 3]; 12] = [
    [2.9762, 4.1296, 6.9406],
    [10.4741, 12.3212, 16.364],
    [21.7781, 24.2761, 29.5147],
    [37.0339, 40.1749, 46.5716],
    [56.2839, 60.0627, 67.6367],
    [79.5329, 83.9383, 92.7136],
    [106.7351, 111.7797, 121.7375],
    [137.9954, 143.6691, 154.7977],
    [173.2292, 179.5199, 191.8122],
    [212.4721, 219.4051, 232.8291],
    [255.6732, 263.2603, 277.9962],
    [302.9054, 311.1288, 326.9716],
];

/// Trace critical values, `p = 0`.
const TJCP1: [[f64; 3]; 12] = [
    [2.7055, 3.8415, 6.6349],
    [13.4294, 15.4943, 19.9349],
    [27.0669, 29.7961, 35.4628],
    [44.4929, 47.8545, 54.6815],
    [65.8202, 69.8189, 77.8202],
    [91.109, 95.7542, 104.9637],
    [120.3673, 125.6185, 135.9825],
    [153.6341, 159.529, 171.0905],
    [190.8714, 197.3772, 210.0366],
    [232.103, 239.2468, 253.2526],
    [277.374, 285.1402, 300.2821],
    [326.5354, 334.9795, 351.215],
];

/// Trace critical values, `p = 1`.
const TJCP2: [[f64; 3]; 12] = [
    [2.7055, 3.8415, 6.6349],
    [16.1619, 18.3985, 23.1485],
    [32.0645, 35.0116, 41.0815],
    [51.6492, 55.2459, 62.5202],
    [75.1027, 79.3422, 87.7748],
    [102.4674, 107.3429, 116.9829],
    [133.7852, 139.278, 150.0778],
    [169.0618, 175.1584, 187.1891],
    [208.3582, 215.1268, 228.2226],
    [251.6293, 259.0267, 273.3838],
    [298.8836, 306.8988, 322.4264],
    [350.1125, 358.719, 375.3203],
];

const NAN3: [f64; 3] = [f64::NAN, f64::NAN, f64::NAN];

/// Maximum-eigenvalue critical values for `n` common trends and deterministic
/// order `p` (reference `c_sja`).
pub fn c_sja(n: usize, p: i32) -> [f64; 3] {
    if !(-1..=1).contains(&p) || !(1..=12).contains(&n) {
        return NAN3;
    }
    match p {
        -1 => EJCP0[n - 1],
        0 => EJCP1[n - 1],
        _ => EJCP2[n - 1],
    }
}

/// Trace critical values for `n` common trends and deterministic order `p`
/// (reference `c_sjt`).
pub fn c_sjt(n: usize, p: i32) -> [f64; 3] {
    if !(-1..=1).contains(&p) || !(1..=12).contains(&n) {
        return NAN3;
    }
    match p {
        -1 => TJCP0[n - 1],
        0 => TJCP1[n - 1],
        _ => TJCP2[n - 1],
    }
}