Trait augurs_mstl::TrendModel
source · 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§
sourcefn fit(
&mut self,
y: &[f64]
) -> Result<(), Box<dyn Error + Send + Sync + 'static>>
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.
sourcefn predict(
&self,
horizon: usize,
level: Option<f64>
) -> Result<Forecast, Box<dyn Error + Send + Sync + 'static>>
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
.
sourcefn predict_in_sample(
&self,
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>>
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
.