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>

source

pub fn naive(periods: Vec<usize>) -> Self

Create a new MSTL model with a naive trend model.

The naive trend model predicts the last value in the training set and so is unlikely to be useful for real applications, but it can be useful for testing, benchmarking and pedagogy.

source§

impl<T: TrendModel, F> MSTLModel<T, F>

source

pub fn trend_model(&self) -> &T

Return a reference to the trend model.

source§

impl<T: TrendModel> MSTLModel<T, Unfit>

source

pub fn new(periods: Vec<usize>, trend_model: T) -> Self

Create a new MSTL model with the given trend model.

source

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.

source

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].

source

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>

source

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.

source

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.

source

pub fn fit(&self) -> &MstlResult

Return the MSTL fit of the training data.

Trait Implementations§

source§

impl<T: Debug, F: Debug> Debug for MSTLModel<T, F>

source§

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

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<T, F> RefUnwindSafe for MSTLModel<T, F>

§

impl<T, F> Send for MSTLModel<T, F>
where F: Send, T: Send,

§

impl<T, F> Sync for MSTLModel<T, F>
where F: Sync, T: Sync,

§

impl<T, F> Unpin for MSTLModel<T, F>
where F: Unpin, T: Unpin,

§

impl<T, F> UnwindSafe for MSTLModel<T, F>
where F: UnwindSafe, T: UnwindSafe,

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<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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, U> TryFrom<U> for T
where U: Into<T>,

§

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>,

§

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<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more