I got some problems predicting my arima model when I use expanding window function. My code looks like this:
iTraininSet <- trunc(nrow(adj_consumption)*0.7)
iValidationSet <- trunc(nrow(adj_consumption)*0.1)
iEstimation <- iTraininSet + iValidationSet
iOOS <- trunc(nrow(adj_consumption)*0.2)
OOS_Arima <- matrix(data = NA, nrow = iOOS, ncol = 1)
Actual_OLS <- matrix(data = NA, nrow = iOOS, ncol =1)
Bech_OLS <- matrix(data = NA, nrow = iOOS, ncol = 1)
dfDataArima <- ts(adj_consumption, freq=12, start = c(2008,1), end = c(2019,12))
for(i in 1:iOOS) {
modely <-Arima(dfDataArima[1:iEstimation+i,], order=c(0,1,1))
OOS_Arima[i,] <- predict(modely, newdata = dfDataArima[iEstimation+i,])
}
The error is:
Error in OOS_Arima[i, ] <- predict(modely, newdata = dfDataArima[iEstimation + :
number of items to replace is not a multiple of replacement length
Does anyone have a suggestion to fix this. I have used this method with OLS, LASSO and Ridge and it worked fine, but I can't make it work with Arima.