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: f64Mean 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
impl SarimaModel
Sourcepub fn fit(data: &Array1<f64>, order: SarimaOrder) -> Result<Self>
pub fn fit(data: &Array1<f64>, order: SarimaOrder) -> Result<Self>
Primary constructor for fitting SARIMA/ARIMA models (Conditional Sum of Squares estimation).
Sourcepub fn fit_with_method(
data: &Array1<f64>,
order: SarimaOrder,
method: EstimationMethod,
) -> Result<Self>
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.
Sourcepub fn fit_transformed(
data: &Array1<f64>,
order: SarimaOrder,
method: EstimationMethod,
transform: Option<f64>,
) -> Result<Self>
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.
Sourcepub fn residuals(&self, data: &Array1<f64>) -> Array1<f64>
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.
Sourcepub fn fit_with_exog(
y: &Array1<f64>,
exog: Option<&Array2<f64>>,
order: SarimaOrder,
) -> Result<Self>
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.
Sourcepub fn forecast_with_intervals_exog(
&self,
data: &Array1<f64>,
exog_hist: Option<&Array2<f64>>,
exog_future: Option<&Array2<f64>>,
steps: usize,
) -> Result<ForecastResult>
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.
pub fn forecast_with_intervals( &self, data: &Array1<f64>, steps: usize, ) -> ForecastResult
Sourcepub fn fit_arima(
data: &Array1<f64>,
p: usize,
d: usize,
q: usize,
) -> Result<Self>
pub fn fit_arima( data: &Array1<f64>, p: usize, d: usize, q: usize, ) -> Result<Self>
Convenience shortcut for non-seasonal ARIMA
Sourcepub fn is_pure_arima(&self) -> bool
pub fn is_pure_arima(&self) -> bool
Returns true if the fitted model is purely non-seasonal
pub fn aic(&self) -> f64
pub fn aicc(&self, n: usize) -> f64
pub fn bic(&self, n: usize) -> f64
Trait Implementations§
Source§impl Clone for SarimaModel
impl Clone for SarimaModel
Source§fn clone(&self) -> SarimaModel
fn clone(&self) -> SarimaModel
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for SarimaModel
impl Debug for SarimaModel
Source§impl<'de> Deserialize<'de> for SarimaModel
impl<'de> Deserialize<'de> for SarimaModel
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for SarimaModel
impl RefUnwindSafe for SarimaModel
impl Send for SarimaModel
impl Sync for SarimaModel
impl Unpin for SarimaModel
impl UnsafeUnpin for SarimaModel
impl UnwindSafe for SarimaModel
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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