# NOT RUN {
## Estimate coefficients of different realized variance models
data("RV")
RV2 <- head(RV, 2000)
RV <- RV2$RV
RV_week <- RV2$RV_week
RV_month <- RV2$RV_month
RQ <- RV2$RQ_lag_sqrt
##Corsi (2009) HAR model
HAR <- arima(RV, order = c(1, 0, 0), xreg = cbind (RV_week, RV_month))
print(HAR)
##Chen et al (2017) TVCHAR model
TVCHAR <- tvAR (RV, p = 1, exogen = cbind (RV_week, RV_month), bw = 20)
print(TVCHAR)
##Casas et al (2018) TVHARQ model
TVHARQ <- tvAR (RV, p = 1, exogen = cbind (RV_week, RV_month),
z=RQ, bw = 0.0062)
print(TVHARQ)
# }
Run the code above in your browser using DataLab