[New Model] Forecasting with Moving Average
Is your feature request related to a current problem? Please describe.
Moving Average (MA) is used as a "baseline model" in many time-series forecasting use cases. With the current darts library, we only have access to MA as:
- a Filtering Model (issue: only applicable to past time series),
- or as a special case of the ARIMA models (issue: quite slow, if in the end all we want to obtain is a MA).
Describe proposed solution
Implement MA as a Forecasting Model class, so all the underlying functions (fit, predict, backtesting, gridsearch, etc.) can be used. Potentially the work already done for MA Filtering Model can be leveraged.
Describe potential alternatives
- An example or code snippet on how to use the existing MA Filtering Model for this purpose (viz. predict, not filter). This is somewhat what I expected to find in this example (https://unit8co.github.io/darts/examples/10-Kalman-filter-examples.html) upon reading its title ("Filtering and predicting using the darts filters").
- Speed up ARIMA models drastically if a pure MA is requested.
Thanks in any case for the great library, awesome work!
+1, adding to our backlog, thanks for the suggestion. Also, please let us know if you would be interesting to make a contribution around this.
@hrzn my Python and GitHub chops need to improve a lot before I can confidently contribute, but if there are any non-technical improvements you might already have identified, glad to help there.
In the meantime we'll have a look at open issues in case we can shed light on some of them.
Since the model is first fit and then used to predict future values, the prediction of a moving average model would always be the mean of the last window number of values in the time series used for training (with a constant value as the prediction independent of the forecast horizon). This would be equivalent to using the NaiveMean on the last window of the time series. Is this logic correct?
Since the model is first fit and then used to predict future values, the prediction of a moving average model would always be the mean of the last
windownumber of values in the time series used for training (with a constant value as the prediction independent of the forecast horizon). This would be equivalent to using theNaiveMeanon the lastwindowof the time series. Is this logic correct?
Yes I think that's correct.
@hrzn Hi, could I pick up this issue?
@JanFidor yes, that'd be great! On second thoughts though I'm not quite sure this statement was correct:
Since the model is first fit and then used to predict future values, the prediction of a moving average model would always be the mean of the last window number of values in the time series used for training (with a constant value as the prediction independent of the forecast horizon). This would be equivalent to using the NaiveMean on the last window of the time series. Is this logic correct?
Rather I think for forecasting a horizon of n future points using a moving average, this would have to be done auto-regressively:
- forecasting first the point
t+1as the average of the precedingt-w+1, ..., ttime steps, - the second point
t+2as the average of the precedingt-w+2, ..., t+1time steps, - .. etc all the way up to
t + n.
where w is the window length and the model parameter.
Would this make sense? There might be something in Pandas we could reuse.
There was an initial attempt here as well: https://github.com/unit8co/darts/pull/1201 but it required changes so we could also start over.