Skip to main content

SarimaModel

Struct SarimaModel 

Source
pub struct SarimaModel {
    pub order: SarimaOrder,
    pub ar_coeffs: Array1<f64>,
    pub ma_coeffs: Array1<f64>,
    pub sar_coeffs: Array1<f64>,
    pub sma_coeffs: Array1<f64>,
    pub sigma2: f64,
    pub log_likelihood: f64,
    pub intercept: f64,
    pub std_errors: Option<Array1<f64>>,
    pub transform: Option<f64>,
    pub exog_beta: Option<Array1<f64>>,
}

Fields§

§order: SarimaOrder§ar_coeffs: Array1<f64>§ma_coeffs: Array1<f64>§sar_coeffs: Array1<f64>§sma_coeffs: Array1<f64>§sigma2: f64§log_likelihood: f64§intercept: f64

Mean of the (differenced) series, added back during forecasting. Estimated only when total differencing d + D <= 1 (a mean for d+D == 0, a drift for d+D == 1); otherwise 0.0.

§std_errors: Option<Array1<f64>>

Asymptotic standard errors of the estimated coefficients, in the order [ar.., ma.., sar.., sma..]. None if they could not be computed.

§transform: Option<f64>

Box-Cox transform parameter applied to the data before fitting (Some(0.0) is a log transform); forecasts are back-transformed. None means no transform.

§exog_beta: Option<Array1<f64>>

Implementations§

Source§

impl SarimaModel

Source

pub fn fit(data: &Array1<f64>, order: SarimaOrder) -> Result<Self>

Primary constructor for fitting SARIMA/ARIMA models (Conditional Sum of Squares estimation).

Source

pub fn fit_with_method( data: &Array1<f64>, order: SarimaOrder, method: EstimationMethod, ) -> Result<Self>

Fits a SARIMA/ARIMA model with an explicit estimation method.

  • EstimationMethod::Css — fast Conditional Sum of Squares (default).
  • EstimationMethod::Mle — exact Gaussian maximum likelihood via the Kalman filter; slower but statistically more efficient on short series. Falls back to CSS if the likelihood optimization fails.
Source

pub fn fit_transformed( data: &Array1<f64>, order: SarimaOrder, method: EstimationMethod, transform: Option<f64>, ) -> Result<Self>

Fits a model to Box-Cox-transformed data (transform = lambda; Some(0.0) is a log transform). Requires strictly positive input; forecasts produced by the returned model are automatically back-transformed to the original scale.

Source

pub fn residuals(&self, data: &Array1<f64>) -> Array1<f64>

Returns the model’s in-sample one-step innovation residuals (on the differenced, mean-centered scale the ARMA part was fitted on). These feed the residual diagnostics in crate::diagnostics.

Source

pub fn fit_with_exog( y: &Array1<f64>, exog: Option<&Array2<f64>>, order: SarimaOrder, ) -> Result<Self>

Fits a SARIMAX model. If exog is provided, it first removes the linear trend contributed by X and then fits the SARIMA parameters on the regression residuals.

Source

pub fn forecast_with_intervals_exog( &self, data: &Array1<f64>, exog_hist: Option<&Array2<f64>>, exog_future: Option<&Array2<f64>>, steps: usize, ) -> Result<ForecastResult>

Forecasts a SARIMAX model fitted via Self::fit_with_exog.

The SARIMA dynamics were estimated on the regression residuals eta = y - X * beta, so forecasting requires the historical exogenous matrix exog_hist to reconstruct that residual series, then adds the future exogenous contribution X_fut * beta back onto every band.

For a model fitted without exogenous variables this reduces to Self::forecast_with_intervals; exog_hist/exog_future are ignored.

Source

pub fn forecast_with_intervals( &self, data: &Array1<f64>, steps: usize, ) -> ForecastResult

Source

pub fn fit_arima( data: &Array1<f64>, p: usize, d: usize, q: usize, ) -> Result<Self>

Convenience shortcut for non-seasonal ARIMA

Source

pub fn is_pure_arima(&self) -> bool

Returns true if the fitted model is purely non-seasonal

Source

pub fn aic(&self) -> f64

Source

pub fn aicc(&self, n: usize) -> f64

Source

pub fn bic(&self, n: usize) -> f64

Source

pub fn forecast(&self, history: &Array1<f64>, steps: usize) -> Array1<f64>

Point forecast steps periods ahead. If the model was fitted with a Box-Cox transform, the forecast is automatically back-transformed to the original scale.

Trait Implementations§

Source§

impl Clone for SarimaModel

Source§

fn clone(&self) -> SarimaModel

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SarimaModel

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SarimaModel

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for SarimaModel

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> SendAlias for T

Source§

impl<T> SyncAlias for T

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V