pub trait TrendModel: Debug {
    // Required methods
    fn name(&self) -> Cow<'_, str>;
    fn fit(
        &mut self,
        y: &[f64]
    ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>;
    fn predict(
        &self,
        horizon: usize,
        level: Option<f64>
    ) -> Result<Forecast, Box<dyn Error + Send + Sync + 'static>>;
    fn predict_in_sample(
        &self,
        level: Option<f64>
    ) -> Result<Forecast, Box<dyn Error + Send + Sync + 'static>>;
}
Expand description

A trend model.

Trend models are used to model the trend component of a time series. Examples implemented in other languages include ARIMA, Theta and ETS.

You can implement this trait for your own trend models.

Required Methods§

source

fn name(&self) -> Cow<'_, str>

Return the name of the trend model.

source

fn fit( &mut self, y: &[f64] ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>

Fit the model to the given time series.

This method is called once before any calls to predict or predict_in_sample.

Implementations should store any state required for prediction in the struct itself.

source

fn predict( &self, horizon: usize, level: Option<f64> ) -> Result<Forecast, Box<dyn Error + Send + Sync + 'static>>

Produce a forecast for the next horizon time points.

The level parameter specifies the confidence level for the prediction intervals. Where possible, implementations should provide prediction intervals alongside the point forecasts if level is not None.

source

fn predict_in_sample( &self, level: Option<f64> ) -> Result<Forecast, Box<dyn Error + Send + Sync + 'static>>

Produce in-sample predictions.

In-sample predictions are used to assess the fit of the model to the training data.

The level parameter specifies the confidence level for the prediction intervals. Where possible, implementations should provide prediction intervals alongside the point forecasts if level is not None.

Implementations on Foreign Types§

source§

impl<T: TrendModel + ?Sized> TrendModel for Box<T>

source§

fn name(&self) -> Cow<'_, str>

source§

fn fit( &mut self, y: &[f64] ) -> Result<(), Box<dyn Error + Send + Sync + 'static>>

source§

fn predict( &self, horizon: usize, level: Option<f64> ) -> Result<Forecast, Box<dyn Error + Send + Sync + 'static>>

source§

fn predict_in_sample( &self, level: Option<f64> ) -> Result<Forecast, Box<dyn Error + Send + Sync + 'static>>

Implementors§