使用rugarch软件包在GARCH模型中拟合时间序列数据时发生错误

时间:2018-10-31 10:02:10

标签: r frequency bitcoin

我想使用rugarch软件包分析GARCH对2015年至2018年比特币每日收益的影响。我使用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测试”部分下发生了此错误:“ if(frequency> 1 && abs(frequency-round(frequency))

> 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

有人可以帮助我解决此问题吗?谢谢!

1 个答案:

答案 0 :(得分:0)

不幸的是,我的帖子对您​​没有帮助,但可能是那些搜索相关问题的人,就像我一样。

我有一个类似的问题,估计 gjr-garch 模型导致整个估计的 missing value where TRUE/FALSE needed 错误。在寻找解决方案时,我看到了您的帖子。

我的问题是由缺失值(用 omit.na() 解决)和使用小标题代替数字值(用 as.numeric(unlist()) 解决)引起的。