请选择 进入手机版 | 继续访问电脑版
楼主: cherishlife123
7432 11

[实际应用] rugarch 包编程问题 [推广有奖]

  • 11关注
  • 2粉丝

讲师

72%

还不是VIP/贵宾

-

威望
0
论坛币
1470 个
通用积分
0.6424
学术水平
4 点
热心指数
11 点
信用等级
3 点
经验
19678 点
帖子
307
精华
0
在线时间
747 小时
注册时间
2011-3-9
最后登录
2024-3-19

cherishlife123 学生认证  发表于 2017-4-12 18:45:56 |显示全部楼层 |坛友微信交流群
相似文件 换一批

+2 论坛币
k人 参与回答

经管之家送您一份

应届毕业生专属福利!

求职就业群
赵安豆老师微信:zhaoandou666

经管之家联合CDA

送您一个全额奖学金名额~ !

感谢您参与论坛问题回答

经管之家送您两个论坛币!

+2 论坛币
如题,我想用rugarch包算时间序列的garch模型,包括外生变量,请问该如何编,我的程序问题在哪里。
数据见附件,1.我的变量维度是时间和国家,2.核心变量是 股指年收益率,3.外生变量是第9,10列数据。
aa<-read.csv("aa.csv",stringsAsFactors=F)
library(rugarch)
spec = ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1),external.regressors =aa[,9:10] ),
        mean.model = list(armaOrder = c(1, 1),include.mean = TRUE, arfima = FALSE,external.regressors =aa[,9:10] ),
         distribution.model = "sged")
fit= ugarchfit(spec = spec,aa[,c(1:2,4)])
fit

报错:
Error in optim(init[mask], armaCSS, method = optim.method, hessian = TRUE,  :
  'vmmin'的初始值不能为无穷大

结果里面根本没有外生变量的系数
程序错在哪里?
我的程序还有其他的问题吗?比如我没有特别强调 变量id=(时间,国家),这样我一直有疑惑。
求大神解答! aa.xls (286 KB)
二维码

扫码加我 拉你入群

请注明:姓名-公司-职位

以便审核进群资格,未注明则拒绝

关键词:UGARCH GARCH ARCH ARC RCH

cherishlife123 学生认证  发表于 2017-4-13 07:28:16 |显示全部楼层 |坛友微信交流群
在这里等到天荒地老

使用道具

cherishlife123 学生认证  发表于 2017-4-14 07:36:06 |显示全部楼层 |坛友微信交流群
顶顶顶

使用道具

cherishlife123 学生认证  发表于 2017-4-17 07:32:11 |显示全部楼层 |坛友微信交流群
没人回答?

使用道具

xirongzan 发表于 2017-4-17 15:33:59 |显示全部楼层 |坛友微信交流群
R新手回答,不对请指正。估计是你外部回归元的数据格式问题。例子如下:
gjr.spec <- ugarchspec( # start ugarch specification
    variance.model = list(model = "gjrGARCH", # select Treshold-GARCH
                          garchOrder = c(1, 1), # GARCH(1, 1), order c(1,1) is in fact the default
                          external.regressors = as.matrix(dfr[, "mon"])), # monday effect in variance
                                                               # given as an external regressor. Must be
                                                               # a matrix!
    mean.model = list(armaOrder = c(0, 1), # MA(1) specification
                      external.regressors = as.matrix(dfr[, c("mon")])), # Monday effect in the returns
                                                                  # must be a matrix!
    distribution.model = "sstd" # Student t as the conditional distribution
    ) # end  ugarch specification
已有 1 人评分论坛币 学术水平 热心指数 信用等级 收起 理由
cherishlife123 + 5 + 3 + 3 + 3 热心帮助其他会员

总评分: 论坛币 + 5  学术水平 + 3  热心指数 + 3  信用等级 + 3   查看全部评分

使用道具

cherishlife123 学生认证  发表于 2017-4-18 07:54:43 |显示全部楼层 |坛友微信交流群
xirongzan 发表于 2017-4-17 15:33
R新手回答,不对请指正。估计是你外部回归元的数据格式问题。例子如下:
gjr.spec
感谢你的回答。对我的问题有一定的帮助,但是还没有完全解答我的疑惑

使用道具

cherishlife123 学生认证  发表于 2017-4-19 07:36:42 |显示全部楼层 |坛友微信交流群
一直顶到大神到来

使用道具

cherishlife123 学生认证  发表于 2017-4-20 08:03:50 |显示全部楼层 |坛友微信交流群
再顶顶

使用道具

cherishlife123 学生认证  发表于 2017-4-23 07:42:15 |显示全部楼层 |坛友微信交流群
.....................................................

使用道具

是不是因为没有设界呀?
spec = ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1),external.regressors =aa[,9:10] ),
        mean.model = list(armaOrder = c(1, 1),include.mean = TRUE, arfima = FALSE,external.regressors =aa[,9:10] ),
         distribution.model = "sged")
setbounds(spec)<-list(alpha2=c(-1,1))
fit= ugarchfit(spec = spec,aa[,c(1:2,4)])

使用道具

您需要登录后才可以回帖 登录 | 我要注册

本版微信群
加好友,备注cda
拉您进交流群

京ICP备16021002-2号 京B2-20170662号 京公网安备 11010802022788号 论坛法律顾问:王进律师 知识产权保护声明   免责及隐私声明

GMT+8, 2024-4-18 20:07