我分析了我的国内生产总值时间序列,以便作出预测。我发现最合适的模型是:
garch1b<garchFit(~arma(1,1)+garch(1,1),data=dlogGDP,cond.dist="QMLE")garch6b<garchFit(~arma(1,0)+garch(1,1),data=dlogGDP,cond.dist="QMLE")GDP时间模式

两种模式都是有效的。我想做一个样本外预测性能比较.我使用了这个代码:
# Out-of-sample forcasting performance
y<-dlogGDP
S=round(0.75*length(y))
h=1
error1.h<-c()
for (i in S:(length(y)-h))
{
mymodel.sub<-garchFit(y[1:i], formula = ~arma(1,1)+garch(1,1))
predict.h<-predict(mymodel.sub,n.ahead=h)$pred[h]
error1.h<-c(error1.h,y[i+h]-predict.h)
}
error2.h<-c()
for (i in S:(length(y)-h))
{
mymodel.sub<-garchFit(y[1:i], formula = ~arma(1,0)+garch(1,1))
predict.h<-predict(mymodel.sub,n.ahead=h)$pred[h]
error2.h<-c(error2.h,y[i+h]-predict.h)
}
cbind(error1.h,error2.h)
# Mean Absolute Error
MAE1<-mean(abs(error1.h))
MAE2<-mean(abs(error2.h))
# Mean Squared Forcast Error
MAE1<-mean(abs(error1.h^2))
MAE2<-mean(abs(error2.h^2))
# Forcasting Performance Comparison
library(forecast)
dm.test(error1.h,error2.h,h=h,power=1)
dm.test(error1.h,error2.h,h=h,power=2)然而,我没有得到任何结果。error1.h和error2.h是NaN。
问题:
fGARCH 包( package )来进行非样例预测性能?发布于 2018-07-17 16:22:31
我认为,这只是缺少了一条关于预测输出的详细说明:
for (i in S:(length(y)-h))
{
mymodel.sub<-garchFit(y[1:i], formula = ~arma(1,0)+garch(1,1))
f <- fGarch::predict(mymodel.sub,n.ahead=h)
predict.h<-f$meanForecast
error1.h<-c(error1.h,y[i+h]-predict.h)
}https://stackoverflow.com/questions/47391528
复制相似问题