首页 > 解决方案 > 样本外 VAR(1) 滚动窗口,平均绝对误差

问题描述

请帮忙,任何建议都很重要,谢谢!

我正在尝试计算 VAR(1) 滚动窗口的 MAE(平均绝对误差),但无法解决该错误。代码:

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))

错误信息是:

y[i + h] 中的错误 - predict.h1:二元运算符的非数字参数

试过:

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!

标签: rvector-auto-regression

解决方案


推荐阅读