Please kindly help, any advise counts thanks!
I am trying to calculate the MAE (Mean Absolute Error) for VAR(1) rolling window but cannot resolve the error. Code:
RRECG <- data.frame(na.omit(cbind(R1,R2,E1,C1,G1)))
set.seed(123)
y<-Df$R1
S=171;h=113;
error1.h<-c()
for (i in S:(length(y)-h))
{
VARO.sub<- VAR(na.omit(RRECG[(1:i),],p=1,type="const"))
predict.h1<-predict(VARO.sub,n.ahead=h)
error1.h<-c(error1.h,y[i+h]-predict.h1)
}
summary(abs(error1.h))
Error message is:
Error in y[i + h] - predict.h1 : non-numeric argument to binary operator
Tried:
Also tried:
``` predict.h1<-as.numeric(predict(VARO.sub,n.ahead=h))
But not even close to resolve the issue. Please kindly help, thank you!