backshift 0.3.0

Time-series forecasting checked against R and statsmodels: ARIMA, ETS, Theta, VAR, Croston/TSB, GARCH and changepoint detection, with streaming filters that run without a heap
Documentation
//! R reference vectors for the Croston conformance tests.
//!
//! Generated by `scripts/generate_r_croston_reference.R` with R version 4.4.2 (2024-10-31) and forecast 8.23.0.
//! Do not edit by hand; rerun the script instead.

/// A `croston(values, h = 5, alpha)` forecast.
pub struct CrostonCase {
    /// The demand series, zeros for periods without demand.
    pub values: &'static [f64],
    /// The smoothing parameter of both the sizes and the intervals.
    pub alpha: f64,
    /// The forecast for every horizon (Croston's forecast is flat).
    pub forecast: f64,
    /// The one-step forecast of each value from the values before it; `NaN` until R has
    /// one.
    pub fitted: &'static [f64],
}

/// `croston(values, h = 5, alpha = 0.1)` on 60 values.
pub const SPARSE: CrostonCase = CrostonCase {
    values: &[
        0.0, 0.0, 0.0, 8.18, 1.39, 2.02, 0.0, 0.98, 3.15, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        3.55, 0.0, 0.0, 5.5, 0.0, 3.54, 7.22, 0.0, 0.0, 0.0, 0.0, 0.83, 0.0, 3.01, 0.0, 0.0, 0.0,
        0.0, 0.0, 0.0, 3.11, 1.17, 2.94, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0,
        0.0, 0.0, 0.0, 0.0, 6.31, 0.0, 0.0, 0.0, 1.69,
    ],
    alpha: 0.1,
    forecast: 0.9665171278248254,
    fitted: &[
        f64::NAN,
        0.0,
        0.0,
        0.0,
        2.045,
        2.0272972972972974,
        2.0270845481049564,
        2.0270845481049564,
        1.9335594767264983,
        1.9733345322564824,
        1.9733345322564824,
        1.9733345322564824,
        1.9733345322564824,
        1.9733345322564824,
        1.9733345322564824,
        1.9733345322564824,
        1.9733345322564824,
        1.9733345322564824,
        1.5842824444827746,
        1.5842824444827746,
        1.5842824444827746,
        1.6051106078434487,
        1.6051106078434487,
        1.6147293541459682,
        1.7906830696308969,
        1.7906830696308969,
        1.7906830696308969,
        1.7906830696308969,
        1.7906830696308969,
        1.5494235237562648,
        1.5494235237562648,
        1.5466731621969407,
        1.5466731621969407,
        1.5466731621969407,
        1.5466731621969407,
        1.5466731621969407,
        1.5466731621969407,
        1.5466731621969407,
        1.3327561592815653,
        1.3278928383673394,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.379696685937116,
        1.021458983317619,
        1.021458983317619,
        1.021458983317619,
        1.021458983317619,
    ],
};

/// `croston(values, h = 5, alpha = 0.25)` on 50 values.
pub const FREQUENT: CrostonCase = CrostonCase {
    values: &[
        0.0, 3.82, 0.0, 0.0, 3.17, 1.76, 1.31, 3.38, 0.0, 0.0, 5.43, 0.0, 0.0, 6.18, 2.62, 0.0,
        7.03, 0.0, 2.06, 6.77, 4.43, 6.03, 0.0, 4.04, 0.0, 0.0, 15.28, 0.99, 3.86, 0.0, 3.04, 2.97,
        0.0, 4.72, 0.0, 4.55, 0.0, 2.29, 2.33, 0.0, 1.86, 1.7, 0.0, 2.49, 0.0, 0.0, 0.0, 4.37,
        4.21, 3.77,
    ],
    alpha: 0.25,
    forecast: 2.057319766288197,
    fitted: &[
        f64::NAN,
        0.0,
        1.91,
        1.91,
        1.91,
        1.6255555555555554,
        1.6429032258064515,
        1.5940366972477065,
        1.8863682864450126,
        1.8863682864450126,
        1.8863682864450126,
        1.8561514683153013,
        1.8561514683153013,
        1.8561514683153013,
        1.9265531197301853,
        2.018829472726682,
        2.018829472726682,
        2.410693624061833,
        2.410693624061833,
        2.053330891282669,
        2.7474338244003595,
        3.0234222927476275,
        3.5629721388125746,
        3.5629721388125746,
        3.0635707310710654,
        3.0635707310710654,
        3.0635707310710654,
        3.861175805617694,
        3.43428902892794,
        3.5047198290647525,
        3.5047198290647525,
        2.897148486622369,
        2.9094962690757815,
        2.9094962690757815,
        2.738446194968092,
        2.738446194968092,
        2.6025129394478355,
        2.6025129394478355,
        2.1927566964908007,
        2.214419155939469,
        2.214419155939469,
        1.8339436580719903,
        1.8118543743330038,
        1.8118543743330038,
        1.6387110326093604,
        1.6387110326093604,
        1.6387110326093604,
        1.6387110326093604,
        1.3935219309463927,
        1.760100967859364,
    ],
};

/// All Croston reference cases.
pub const ALL: &[&CrostonCase] = &[&SPARSE, &FREQUENT];