r - 样本外 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!
解决方案
推荐阅读
- json - 在flutter中解析json时如何修复类型错误?
- python - 如何使用 pydantic 链接验证
- excel - 使用参数抛出语法错误调用其他子
- css - 我想像推特一样画垂直线
- node.js - 如何使用资产字段保存记录使用服务器到服务器 cloudkit.js
- javascript - jquery:动态编写确认时,您可以返回真正的函数吗?
- javascript - 调用另一个带有 onload 事件的函数后,函数停止工作
- c# - 正则表达式匹配特定格式:字符串中的 4 个数字和 6 个字符
- c# - 我可以使用 LINQ 为我提供 LIST 中项目的非对象视图吗?
- google-cloud-functions - 如何使用 firebase 功能在对话流上播放音频文件