尝试使用时间序列交叉验证模型获取VAR模型的错误。下面提供了R中的代码。
data(auto) #default R data
ls(auto)
VAR(auto[,c("Mileage","Price")], p=1, type="const") #works and provides output
#trying with tscv
library(fpp2)
library(forecast)
#Code below does not work
tscv_var <- function(x, h){forecast(VAR(x, p=4, type="const"), h=h)}
data <-auto[,c("Mileage","Price")]
tsCV(data, h=12, forecastfunction= tscv_var)
有人可以解释为什么我收到错误消息“ attr(x,“ tsp”)<-值:指定了无效的时间序列参数”吗?