X<- c(3,6,8,10,6,5) If I want to forecast using 3point moving average I use ma(X,3) from forecast package So this is going to give a series of smoothed average. If I want to forecast further 2 points ahead I used forecast (ma(X,3),h=2) So this forecast function doesn't use moving average method to forecast further points Rather it automatically chooses the eye model and forecasts the 2 points further. So my confusion is how do I forecast using 3 point moving average method only, as the forecast function uses ets?
-
1$\begingroup$ Do you want a moving average model (a special case of ARMA model) or a rolling average (an average estimated in a rolling window)? $\endgroup$– Richard HardyCommented Dec 21, 2019 at 16:20
-
$\begingroup$ Rolling average in 3 sliding window, I'm talking about $\endgroup$– ManishaCommented Dec 21, 2019 at 16:21
2 Answers
Moving average does not have the "forecast" functionality, because this is a method for smoothing the time-series, not forecasting. If you wanted to use it for forecasting, the only way that would make sense would be to use as a forecast the mean of the last three points and repeat the value as many times as you want for the forecast window. Beyond the last three points, you have nothing to smooth, and all the following values would average over the same points so they won't change. This is called the "naive". Repeating the last value is called the naïve (or random walk) forecasting method.
Given how small your dataset is, you are rather limited to simple forecasting methods. Using something like the naïve forecast, predicting the mean of the whole dataset, or mean of the last three values is probably not that a bad idea if you have good reason to believe that more recent values tell you more about the future than the rest of the time-series. The mean of the whole dataset (6.33) or of the last three values (7.0) and intervals from such forecasts would be strongly overlapping given the size of the data. If you looked at the 80% prediction interval for the mean forecast, you would be forecasting that the future would be not smaller than the smallest value in the data and not larger than the largest value (2.47-10.19).
Notice that the moving average is not the same as moving average model (see moving-average), which can be used for forecasting.
I took your "toy example" of 6 values ... and executed AUTOBOX ( a forecasting package that I have helped to develop ) and instructed the software to lock in a 3 period weighted average WITH equal coefficients and obtained
Following is the Actual/Fit and Forecast for 6 periods
Here are the 6 period out forecasts .... using monte-carlo bootstrapping rather than presumptive normality for the residuals.
-
-
1$\begingroup$ The question asked about moving average smoothing, not the moving average model. Your answer misses the point, or at least does not state explicitly that what you show refers to using a different method than mentioned by OP. $\endgroup$– TimCommented Dec 30, 2021 at 23:24
-
$\begingroup$ If you us a two period moving average , you are essentially converting an observed series of N observations to a new series that contains N-1 "observations" or values. If you use a 3 period centered filter then you lose 2 values , one at each end. Assumed conversion strategies inject autocorrelation which are then empirically identifiable via the acf/pacf. $\endgroup$ Commented Jan 4, 2022 at 14:16