csv 带虚拟变量的Garch(1,1)

qcuzuvrc  于 2023-09-28  发布在  其他
关注(0)|答案(3)|浏览(110)

我尝试在R中使用Garch(1,1)来估计星期几以及其他参数对Product sells的日志返回(ln(Pt/Pt-1))的影响
我在CSV文件中设置了所有设置,并为每一天设置了一个虚拟变量(D1,D2),值为1 or 0
我在R中构建了以下模型

#Bind Data
ext.reg.D1 <- mydata$D1
ext.reg.D2 <- mydata$D2
ext.reg.D3 <- mydata$D3
ext.reg.D4 <- mydata$D4
ext.reg.D5 <- mydata$D5
ext.reg.D6 <- mydata$D6
ext.reg.D7 <- mydata$D7
ext.reg   <- cbind(ext.reg.D1, ext.reg.D2,   ext.reg.D3,ext.reg.D4,ext.reg.D5,ext.reg.D6)
y <- mydata$log_return

fit.spec <- ugarchspec(variance.model = list(model = "sGARCH", garchOrder = c(1, 1), submodel = NULL, external.regressors = NULL, variance.targeting = FALSE), mean.model = list(armaOrder = c(0, 0), external.regressors = ext.reg), distribution.model = "norm", start.pars = list(), fixed.pars = list()) 
fit <- ugarchfit(data = y, spec = fit.spec)

错误
In .sgarchfit(spec = spec,data = data,out.sample = out.sample,:ugarchfit-->警告:求解程序收敛失败。

有什么办法解决这个问题吗?谢谢
采样数据14行
log_return D5 D6 D7 D1 D2 D3 D4 1 -0.02979189 1 0 0 0 0 0 0 2 17.43188265 0 1 0 0 0 0 0 3 -9.12727223 0 0 1 0 0 0 0 4 2.77744081 0 0 0 1 0 0 0 5 9.62597392 0 0 0 0 1 0 0 6 -0.11614358 0 0 0 0 0 1 0 7 10.81279075 0 0 0 0 0 0 1 8 -1.03825650 1 0 0 0 0 0 0 9 -5.49109661 0 1 0 0 0 0 0 10 -16.81177602 0 0 1 0 0 0 0 11 9.74292804 0 0 0 1 0 0 0 12 15.22583595 0 0 0 0 1 0 0 13 -1.79578436 0 0 0 0 0 1 0 14 0.40559431 0 0 0 0 0 0 1 15 -2.38281092 1 0 0 0 0 0 0 16 -4.88853323 0 1 0 0 0 0 0 17 -16.98493635 0 0 1 0 0 0 0 18 7.57998016 0 0 0 1 0 0 0 19 17.56008274 0 0 0 0 1 0 0 20 -0.46754932 0 0 0 0 0 1 0 21 -1.27007966 0 0 0 0 0 0 1 22 -1.79234966 1 0 0 0 0 0 0 23 -5.79461986 0 1 0 0 0 0 0 24 -17.82636881 0 0 1 0 0 0 0 25 9.48124679 0 0 0 1 0 0 0 26 17.64277207 0 0 0 0 1 0 0 27 -0.71191725 0 0 0 0 0 1 0 28 -1.14937870 0 0 0 0 0 0 1 29 -1.62331777 1 0 0 0 0 0 0 30 -5.52787401 0 1 0 0 0 0 0 31 -18.50034717 0 0 1 0 0 0 0 32 10.31502542 0 0 0 1 0 0 0 33 16.21997258 0 0 0 0 1 0 0 34 -1.09910695 0 0 0 0 0 1 0 35 -0.57416519 0 0 0 0 0 0 1 36 -1.83623328 1 0 0 0 0 0 0 37 -5.48021232 0 1 0 0 0 0 0 38 -20.02869823 0 0 1 0 0 0 0 39 11.48799875 0 0 0 1 0 0 0 40 17.55356524 0 0 0 0 1 0 0 41 -1.45430558 0 0 0 0 0 1 0 42 -2.15287757 0 0 0 0 0 0 1 43 -4.91058837 1 0 0 0 0 0 0 44 -4.35107354 0 1 0 0 0 0 0 45 -19.40533612 0 0 1 0 0 0 0 46 6.47785167 0 0 0 1 0 0 0 47 16.54500844 0 0 0 0 1 0 0 48 1.43266482 0 0 0 0 0 1 0 49 1.91234500 0 0 0 0 0 0 1 50 -1.44926252 1 0 0 0 0 0 0 51 -5.69296574 0 1 0 0 0 0 0 52 -14.21241905 0 0 1 0 0 0 0 53 9.85180551 0 0 0 1 0 0 0 54 16.72072000 0 0 0 0 1 0 0 55 -1.04381003 0 0 0 0 0 1 0 56 -1.49048390 0 0 0 0 0 0 1 57 -2.57835848 1 0 0 0 0 0 0 58 -2.93456505 0 1 0 0 0 0 0 59 -21.27981318 0 0 1 0 0 0 0 60 14.27747712 0 0 0 1 0 0 0 61 15.20376637 0 0 0 0 1 0 0 62 -2.36474181 0 0 0 0 0 1 0 63 -0.12825700 0 0 0 0 0 0 1 64 -2.17755007 1 0 0 0 0 0 0 65 -6.50236487 0 1 0 0 0 0 0 66 -20.40159745 0 0 1 0 0 0 0 67 10.12381534 0 0 0 1 0 0 0 68 19.34672964 0 0 0 0 1 0 0 69 -0.18663788 0 0 0 0 0 1 0 70 -1.26430704 0 0 0 0 0 0 1 71 -2.17712050 1 0 0 0 0 0 0 72 -5.20850527 0 1 0 0 0 0 0 73 -19.00303225 0 0 1 0 0 0 0 74 10.78960865 0 0 0 1 0 0 0 75 16.50911599 0 0 0 0 1 0 0 76 -1.20629718 0 0 0 0 0 1 0 77 -0.92077350 0 0 0 0 0 0 1 78 -2.13818901 1 0 0 0 0 0 0 79 -6.39795596 0 1 0 0 0 0 0 80 -16.89947946 0 0 1 0 0 0 0 81 11.84070286 0 0 0 1 0 0 0 82 16.76126417 0 0 0 0 1 0 0 83 -2.32992683 0 0 0 0 0 1 0 84 -0.04347497 0 0 0 0 0 0 1 85 -1.58421553 1 0 0 0 0 0 0 86 -5.11294741 0 1 0 0 0 0 0 87 -22.94382512 0 0 1 0 0 0 0 88 12.08906834 0 0 0 1 0 0 0 89 18.59588505 0 0 0 0 1 0 0 90 -0.66190281 0 0 0 0 0 1 0 91 -3.35891858 0 0 0 0 0 0 1 92 -5.56096067 1 0 0 0 0 0 0 93 -19.12946131 0 1 0 0 0 0 0 94 -2.45717082 0 0 1 0 0 0 0 95 -6.00314421 0 0 0 1 0 0 0 96 16.87403882 0 0 0 0 1 0 0 97 16.72700765 0 0 0 0 0 1 0 98 -1.80683941 0 0 0 0 0 0 1 99 -2.08228231 1 0 0 0 0 0 0 100 -5.98864409 0 1 0 0 0 0 0 101 -14.91991224 0 0 1 0 0 0 0

vhipe2zx

vhipe2zx1#

我认为问题在于解释变量都是虚拟变量。你应该包含另一个非伪变量,如D1...D7中的x。如果没有这个变量,你的模型就没有意义。你不能只用虚拟变量来估计y(这是一个连续变量)。例如,尝试将y-1添加到ext.reg <- cbind(ext.reg.D1, ext.reg.D2, ext.reg.D3,ext.reg.D4,ext.reg.D5,ext.reg.D6)
好运

hfsqlsce

hfsqlsce2#

为此更改您的**ext.reg**

ext.reg <- cbind(ext.reg.D1, ext.reg.D2, ext.reg.D3, ext.reg.D4, 
                 ext.reg.D5, ext.reg.D6, ext.reg.D7)

男人看,解决运动。

pprl5pva

pprl5pva3#

external.regressors参数应该是一个矩阵对象。那么,你要做的就是:

ext.reg <- data.matrix(cbind(ext.reg.D1, ext.reg.D2, ext.reg.D3, ext.reg.D4, 
                 ext.reg.D5, ext.reg.D6, ext.reg.D7))

相关问题