Crate unit_root

source ·
Expand description

Basic Unit root tests for time series data.

Examples

use unit_root::prelude::distrib::dickeyfuller::get_critical_value;
use unit_root::prelude::distrib::{AlphaLevel, Regression};
use unit_root::prelude::nalgebra::DVector;
use unit_root::prelude::tools::adf_test;
use unit_root::prelude::*;

let y = DVector::from_row_slice(&[
    -0.89642362f64,
    0.3222552,
    -1.96581989,
    -1.10012936,
    -1.3682928,
    1.17239875,
    2.19561259,
    2.54295031,
    2.05530587,
    1.13212955,
    -0.42968979,
]);

let lag = 2;
let regression = Regression::Constant;
let report = adf_test(&y, lag, regression).unwrap();

let critical_value: f64 =
    get_critical_value(regression, report.size, AlphaLevel::OnePercent).unwrap();
assert_eq!(report.size, 8);

let t_stat = report.test_statistic;
println!("t-statistic: {}", t_stat);
println!("critical_value: {}", critical_value);

References

Modules

  • The public API. unit_root is a library for testing for unit roots in time series. This is the public API. Enjoy!

Enums

  • The error type for this crate.