首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >样本外预测性能-R中的fGARCH

样本外预测性能-R中的fGARCH
EN

Stack Overflow用户
提问于 2017-11-20 11:59:22
回答 1查看 405关注 0票数 1

我分析了我的国内生产总值时间序列,以便作出预测。我发现最合适的模型是:

  • GARCH(1,1)与ARMA (1,1):garch1b<garchFit(~arma(1,1)+garch(1,1),data=dlogGDP,cond.dist="QMLE")
  • GARCH(1,1)与ARMA (1,0):garch6b<garchFit(~arma(1,0)+garch(1,1),data=dlogGDP,cond.dist="QMLE")

GDP时间模式

两种模式都是有效的。我想做一个样本外预测性能比较.我使用了这个代码:

代码语言:javascript
复制
# 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.herror2.hNaN

问题:

  1. 我的密码怎么了?
  2. 是否有另一种方法可以使用fGARCH 包( package )来进行非样例预测性能
EN

回答 1

Stack Overflow用户

发布于 2018-07-17 16:22:31

我认为,这只是缺少了一条关于预测输出的详细说明:

代码语言:javascript
复制
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)
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47391528

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档