Struct augurs_mstl::MSTLModel
source · pub struct MSTLModel<T, F> { /* private fields */ }
Expand description
A model that uses the MSTL to decompose a time series into trend, seasonal and remainder components, and then uses a trend model to forecast the trend component.
Implementations§
source§impl MSTLModel<NaiveTrend, Unfit>
impl MSTLModel<NaiveTrend, Unfit>
source§impl<T: TrendModel, F> MSTLModel<T, F>
impl<T: TrendModel, F> MSTLModel<T, F>
sourcepub fn trend_model(&self) -> &T
pub fn trend_model(&self) -> &T
Return a reference to the trend model.
source§impl<T: TrendModel> MSTLModel<T, Unfit>
impl<T: TrendModel> MSTLModel<T, Unfit>
sourcepub fn new(periods: Vec<usize>, trend_model: T) -> Self
pub fn new(periods: Vec<usize>, trend_model: T) -> Self
Create a new MSTL model with the given trend model.
sourcepub fn impute(self, impute: bool) -> Self
pub fn impute(self, impute: bool) -> Self
Set whether to impute missing values in the time series.
If true
, then missing values will be imputed using
linear interpolation before fitting the model.
sourcepub fn mstl_params(self, params: MstlParams) -> Self
pub fn mstl_params(self, params: MstlParams) -> Self
Set the parameters for the MSTL algorithm.
This can be used to control the parameters for the inner STL algorithm
by using [MstlParams::stl_params
].
sourcepub fn fit(self, y: &[f64]) -> Result<MSTLModel<T, Fit>, Error>
pub fn fit(self, y: &[f64]) -> Result<MSTLModel<T, Fit>, Error>
Fit the model to the given time series.
§Errors
If no periods are specified, or if all periods are greater than half the length of the time series, then an error is returned.
Any errors returned by the STL algorithm or trend model are also propagated.
source§impl<T: TrendModel> MSTLModel<T, Fit>
impl<T: TrendModel> MSTLModel<T, Fit>
sourcepub fn predict(
&self,
horizon: usize,
level: impl Into<Option<f64>>
) -> Result<Forecast, Error>
pub fn predict( &self, horizon: usize, level: impl Into<Option<f64>> ) -> Result<Forecast, Error>
Return the n-ahead predictions for the given horizon.
The predictions are point forecasts and optionally include
prediction intervals at the specified level
.
level
should be a float between 0 and 1 representing the
confidence level of the prediction intervals. If None
then
no prediction intervals are returned.
§Errors
Any errors returned by the trend model are propagated.
sourcepub fn predict_in_sample(
&self,
level: impl Into<Option<f64>>
) -> Result<Forecast, Error>
pub fn predict_in_sample( &self, level: impl Into<Option<f64>> ) -> Result<Forecast, Error>
Return the in-sample predictions.
The predictions are point forecasts and optionally include
prediction intervals at the specified level
.
level
should be a float between 0 and 1 representing the
confidence level of the prediction intervals. If None
then
no prediction intervals are returned.
§Errors
Any errors returned by the trend model are propagated.
sourcepub fn fit(&self) -> &MstlResult
pub fn fit(&self) -> &MstlResult
Return the MSTL fit of the training data.