已实现 GARCH - 在模型拟合中指定“realizedVol”
Realized GARCH - specify “realizedVol” in the model fit
我想估计已实现的 GARCH (1,1) 模型。在我的数据集中,我有以下时间序列:
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 must be an xts object
我尝试使用 xts 包描述中给出的示例将我的 RV 矩阵转换为 xts 对象:
require(xts)
rownames(RV) <- date
matrix_xts <- as.xts(RV,dateFormat='Date')
或
df_xts <- as.xts(as.data.frame(RV))
在这两种情况下,错误都是字符串不是标准的明确格式
那么,我应该怎么做才能为 realizedVol 规范制作一个合适的 xts objest 格式?
您应该同时拥有 ret
和 RV
作为 xts
对象,它们可以通过以下方式初始化:
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)
我想估计已实现的 GARCH (1,1) 模型。在我的数据集中,我有以下时间序列:
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 must be an xts object
我尝试使用 xts 包描述中给出的示例将我的 RV 矩阵转换为 xts 对象:
require(xts)
rownames(RV) <- date
matrix_xts <- as.xts(RV,dateFormat='Date')
或
df_xts <- as.xts(as.data.frame(RV))
在这两种情况下,错误都是字符串不是标准的明确格式
那么,我应该怎么做才能为 realizedVol 规范制作一个合适的 xts objest 格式?
您应该同时拥有 ret
和 RV
作为 xts
对象,它们可以通过以下方式初始化:
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)