how to use forecast function for simple moving average model in r?
11,435
For a moving average model you can read here
"Since the model assumes a constant underlying mean, the forecast for any number of periods in the future is the same...".
So, your result are to be expected considering the characteristics of the moving average mode.
Author by
areddy
Updated on June 12, 2022Comments
-
areddy almost 2 years
I want to predict the future values for my simple moving average model. I used the following procedure:
x <- c(14,10,11,7,10,9,11,19,7,10,21,9,8,16,21,14,6,7) df <- data.frame(x) dftimeseries <- ts(df) library(TTR) smadf <- SMA(dftimeseries, 4) # lag is 4 library(forecast) forecasteddf <- forecast(smadf, 4) # future 4 values
When run the above code, my forecast values are the same for all the next 4 days. Am I coding it correctly? Or, am I conceptually wrong?
The same is the case with exponential moving average, weighted moving average, and ARIMA also.