2016-04-07 45 views
1

我想估計已實現的GARCH(1,1)模型。在我的數據集,我有以下時間序列:已實現的GARCH - 在模型中指定了「已實現的沃爾」

ret <- replicate(1, rnorm(100)) 
RV <- replicate(1, rnorm(100)) 
date <- c(1:100) 

我做到以下幾點:

install.packages("rugarch") 
library(rugarch) 
attspec <- ugarchspec(mean.model = list(armaOrder = c(0, 0), include.mean = FALSE), variance.model = list(model = 'realGARCH', garchOrder = c(1, 1))) 
fit <- ugarchfit(spec=attspec, data=ret, solver = 'hybrid', realizedVol = RV[, 1]) 

最後一行後,我得到一個錯誤:realizedVol必須是XTS對象

我嘗試使用xts包中描述的示例將我的RV矩陣轉換爲xts對象:

require(xts) 
rownames(RV) <- date 
matrix_xts <- as.xts(RV,dateFormat='Date') 

df_xts <- as.xts(as.data.frame(RV)) 

在這兩種情況下,錯誤是字符串不是標準明確的格式

所以,我應該爲了讓XTS objest爲合適的格式做實現了VOL規格?

回答

3

你應該有兩個retRVxts對象,他們可以通過以下方式進行初始化:

times<-Sys.time()+date 
ret_xts<-xts(ret,order.by = times) 
RV_xts <- xts(RV,order.by = times) 

,然後就可以順利撥打:

fit <- ugarchfit(spec=attspec, data=ret_xts, solver = 'hybrid', realizedVol = RV_xts) 
+0

做這些錯誤信息的意思: 警告消息: 1:In log(實現[1:長度(數據)]):產生的NaN 2:在.makefitmodel(garchmodel =「realGARCH」,f = .realgarchLLH,T = T,:rugarch - >警告:未能反轉粗麻布 – glarys

+0

這與診斷有關 – adaien

相關問題