arima_forecast

Function arima_forecast 

Source
pub fn arima_forecast<F: Fn(usize, &mut T) -> f64, T: Rng>(
    ts: &[f64],
    n: usize,
    ar: Option<&[f64]>,
    ma: Option<&[f64]>,
    d: usize,
    noise_fn: &F,
    rng: &mut T,
) -> Result<Vec<f64>>
Expand description

Forecast an ARIMA model time series

§Arguments

  • ts - Time series to forecast from
  • n - Length to forecast
  • ar - Model parameters for the AR part
  • ma - Model parameters for the MA part
  • d - Model parameter for the differences
  • noise_fn - Function that takes a `Rng’ as input and returns noise
  • rng - Reference to a mutable Rng.

§Returns

  • Output vector of length n containing the time series data.

§Example

use rand::prelude::*;
use rand_distr::{Distribution, Normal};

let normal = Normal::new(0.0, 2.0).unwrap();

let ts = [0.632, 0.594, -2.750, -5.389, -5.645, -7.672, -12.595, -18.260, -24.147, -31.427];

let x = arima::sim::arima_forecast(
    &ts,
    100,
    Some(&[0.9, -0.3, 0.2]),
    Some(&[0.4, 0.2]),
    1,
    &|i, mut rng| { normal.sample(&mut rng) },
    &mut thread_rng()
).unwrap();