I want to estimate Realized GARCH (1,1) model. In my dataset I have the following time series:
ret <- replicate(1, rnorm(100))
RV <- replicate(1, rnorm(100))
date <- c(1:100)
I do the following:
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])
After the last line I get an error: realizedVol must be an xts object
I tried to convert my RV matrix into xts object using the examples given in the description of the xts package:
require(xts)
rownames(RV) <- date
matrix_xts <- as.xts(RV,dateFormat='Date')
or
df_xts <- as.xts(as.data.frame(RV))
In both cases the error is character string is not in a standard unambiguous format
So, what should I do in order to make a suitable format of xts objest for the realizedVol specification?
You should have both ret
and RV
as xts
objects, they can be initialized in the following way:
times<-Sys.time()+date
ret_xts<-xts(ret,order.by = times)
RV_xts <- xts(RV,order.by = times)
and then you can successfully call:
fit <- ugarchfit(spec=attspec, data=ret_xts, solver = 'hybrid', realizedVol = RV_xts)