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.
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.
The forecast is from the fpp2 package and the moving average function is from the smooth package.
This is an example:
library(smooth)
library(fpp2)
library(readxl)
setwd("C:\Users\lferreira\Desktop\FORECASTING")
data<- read_xlsx("BASE_TESTE.xlsx")
ts <- ts(data$1740
,start=c(2014,1),frequency=4)
fc <- forecast(sma(ts),h=3)
Error: The provided model is not Simple Moving Average!