我想使用rugarch软件包分析2015年至2018年GARCH对比特币日收益的影响。我使用zoo包从csv文件导入了数据,我的数据头(BTC_Return(看起来像这样:
2015-01-02 2015-01-03 2015-01-04 2015-01-05 2015-01-06 2015-01-07
0.001015636 -0.093303963 -0.081262425 0.037516428 0.026674925 0.031626936
当我试图拟合GARCH(1,1(模型中的数据时,这个错误发生在加权ARCH LM测试部分:"如果(频率>1&&abs(频率-舍入(频率((<ts.eps(频率<-舍入(频率(中的错误:需要TRUE/FALSE的地方缺少值"。这是我使用的代码:
> library(zoo)
> BTC_Return <- read.zoo('BTC_Data.csv', header = TRUE, sep = ",", index.column = 1, format = "%Y/%m/%d")
> class(BTC_Return)
> BTC_Return_garch11_spec <- ugarchspec(variance.model = list(garchOrder = c(1,1)), mean.model = list(armaOrder = c(0,0)))
> BTC_Return_garch11_fit <- ugarchfit(spec = BTC_Return_garch11_spec, data = BTC_Return)
> BTC_Return_garch11_fit
*---------------------------------*
* GARCH Model Fit *
*---------------------------------*
Conditional Variance Dynamics
-----------------------------------
GARCH Model : sGARCH(1,1)
Mean Model : ARFIMA(0,0,0)
Distribution : norm
Optimal Parameters
------------------------------------
Estimate Std. Error t value Pr(>|t|)
mu 0.001887 0.000717 2.6322 0.008484
omega 0.000024 0.000007 3.3136 0.000921
alpha1 0.142601 0.019727 7.2289 0.000000
beta1 0.856399 0.018160 47.1585 0.000000
Robust Standard Errors:
Estimate Std. Error t value Pr(>|t|)
mu 0.001887 0.000766 2.4628 0.013786
omega 0.000024 0.000017 1.3863 0.165640
alpha1 0.142601 0.041243 3.4576 0.000545
beta1 0.856399 0.041346 20.7129 0.000000
LogLikelihood : 2685.051
Information Criteria
------------------------------------
Akaike -3.9254
Bayes -3.9101
Shibata -3.9254
Hannan-Quinn -3.9197
Weighted Ljung-Box Test on Standardized Residuals
------------------------------------
statistic p-value
Lag[1] 5.321 0.02107
Lag[2*(p+q)+(p+q)-1][2] 5.997 0.02203
Lag[4*(p+q)+(p+q)-1][5] 7.863 0.03187
d.o.f=0
H0 : No serial correlation
Weighted Ljung-Box Test on Standardized Squared Residuals
------------------------------------
statistic p-value
Lag[1] 5.192 0.02269
Lag[2*(p+q)+(p+q)-1][5] 7.363 0.04230
Lag[4*(p+q)+(p+q)-1][9] 8.637 0.09635
d.o.f=2
Weighted ARCH LM Tests
------------------------------------
Error in if (frequency > 1 && abs(frequency - round(frequency)) < ts.eps) frequency <- round(frequency) :
missing value where TRUE/FALSE needed
有人能帮我解决这个问题吗?谢谢
不幸的是,我的帖子对你没有帮助,但可能对那些搜索相关问题的人没有帮助,就像我一样。
我也遇到过类似的问题,估计gjr-garch模型会导致整个估计的missing value where TRUE/FALSE needed
-误差。在寻找解决方案时,我发现了你的帖子。
我的问题是由于缺少值(用omit.na()
解决(和使用tibble而不是数值(用as.numeric(unlist())
解决(造成的。