HARmodel {highfrequency} | R Documentation |
Heterogeneous autoregressive (HAR) model for realized volatility model estimation
Description
Function returns the estimates for the heterogeneous autoregressive model (HAR) for realized volatility discussed in Andersen et al. (2007) and Corsi (2009). This model is mainly used to forecast the next day's volatility based on the high-frequency returns of the past.
Usage
HARmodel(
data,
periods = c(1, 5, 22),
periodsJ = c(1, 5, 22),
periodsQ = c(1),
leverage = NULL,
RVest = c("rCov", "rBPCov", "rQuar"),
type = "HAR",
inputType = "RM",
jumpTest = "ABDJumptest",
alpha = 0.05,
h = 1,
transform = NULL,
externalRegressor = NULL,
periodsExternal = c(1),
...
)
Arguments
data |
an |
periods |
a vector of integers indicating over how days the realized measures in the model should be aggregated.
By default |
periodsJ |
a vector of integers indicating over what time periods the jump components in the model should be aggregated.
By default |
periodsQ |
a vector of integers indicating over what time periods the realized quarticity in the model should be aggregated.
By default |
leverage |
a vector of integers indicating over what periods the negative returns should be aggregated.
See Corsi and Reno (2012) for more information. By default |
RVest |
a character vector with one, two, or three elements. The first element always refers to the name of the function to estimate the daily integrated variance (non-jump-robust).
The second and third element depends on which type of model is estimated:
If |
type |
a string referring to the type of HAR model you would like to estimate. By default |
inputType |
a string denoting if the input data consists of realized measures or high-frequency returns. Default "RM" is the only way to denote realized measures and everything else denotes returns. |
jumpTest |
the function name of a function used to test whether the test statistic which determines whether the jump variability is significant that day. By default |
alpha |
a real indicating the confidence level used in testing for jumps. By default |
h |
an integer indicating the number over how many days the dependent variable should be aggregated.
By default, |
transform |
optionally a string referring to a function that transforms both the dependent and explanatory variables in the model. By default |
externalRegressor |
an |
periodsExternal |
a vector of integers indicating over how days |
... |
extra arguments for jump test. |
Details
The basic specification in Corsi (2009) is as follows.
Let RV_{t}
be the realized variances at day t
and RV_{t-k:t}
the average
realized variance in between t-k
and t
, k \geq 0
.
The dynamics of the model are given by
RV_{t+1} = \beta_0 + \beta_1 \ RV_{t} + \beta_2 \ RV_{t-4:t} + \beta_3 \ RV_{t-21:t} + \varepsilon_{t+1}
which is estimated by ordinary least squares under the assumption that at time t
,
the conditional mean of \varepsilon_{t+1}
is equal to zero.
For other specifications, please refer to the cited papers.
The standard errors reporting in the print
and summary
methods are Newey-West standard errors calculated with the sandwich package.
Value
The function outputs an object of class HARmodel
and lm
(so HARmodel
is a subclass of lm
). Objects
of class HARmodel
has the following methods plot.HARmodel
, predict.HARmodel
, print.HARmodel
, and summary.HARmodel
.
Author(s)
Jonathan Cornelissen, Kris Boudt, Onno Kleen, and Emil Sjoerup.
References
Andersen, T. G., Bollerslev, T., and Diebold, F. (2007). Roughing it up: Including jump components in the measurement, modelling and forecasting of return volatility. The Review of Economics and Statistics, 89, 701-720.
Corsi, F. (2009). A simple approximate long memory model of realized volatility. Journal of Financial Econometrics, 7, 174-196.
Corsi, F. and Reno R. (2012). Discrete-time volatility forecasting with persistent leverage effect and the link with continuous-time volatility modeling. Journal of Business & Economic Statistics, 30, 368-380.
Bollerslev, T., Patton, A., and Quaedvlieg, R. (2016). Exploiting the errors: A simple approach for improved volatility forecasting, Journal of Econometrics, 192, 1-18.
Examples
# Example 1: HAR
# Forecasting daily Realized volatility for the S&P 500 using the basic HARmodel: HAR
library(xts)
RVSPY <- as.xts(SPYRM$RV5, order.by = SPYRM$DT)
x <- HARmodel(data = RVSPY , periods = c(1,5,22), RVest = c("rCov"),
type = "HAR", h = 1, transform = NULL, inputType = "RM")
class(x)
x
summary(x)
plot(x)
predict(x)
# Example 2: HARQ
# Get the highfrequency returns
dat <- as.xts(sampleOneMinuteData[, makeReturns(STOCK), by = list(DATE = as.Date(DT))])
x <- HARmodel(dat, periods = c(1,5,10), periodsJ = c(1,5,10),
periodsQ = c(1), RVest = c("rCov", "rQuar"),
type="HARQ", inputType = "returns")
# Estimate the HAR model of type HARQ
class(x)
x
# plot(x)
# predict(x)
# Example 3: HARQJ with already computed realized measures
dat <- SPYRM[, list(DT, RV5, BPV5, RQ5)]
x <- HARmodel(as.xts(dat), periods = c(1,5,22), periodsJ = c(1),
periodsQ = c(1), type = "HARQJ")
# Estimate the HAR model of type HARQJ
class(x)
x
# plot(x)
predict(x)
# Example 4: CHAR with already computed realized measures
dat <- SPYRM[, list(DT, RV5, BPV5)]
x <- HARmodel(as.xts(dat), periods = c(1, 5, 22), type = "CHAR")
# Estimate the HAR model of type CHAR
class(x)
x
# plot(x)
predict(x)
# Example 5: CHARQ with already computed realized measures
dat <- SPYRM[, list(DT, RV5, BPV5, RQ5)]
x <- HARmodel(as.xts(dat), periods = c(1,5,22), periodsQ = c(1), type = "CHARQ")
# Estimate the HAR model of type CHARQ
class(x)
x
# plot(x)
predict(x)
# Example 6: HARCJ with pre-computed test-statistics
## BNSJumptest manually calculated.
testStats <- sqrt(390) * (SPYRM$RV1 - SPYRM$BPV1)/sqrt((pi^2/4+pi-3 - 2) * SPYRM$medRQ1)
model <- HARmodel(cbind(as.xts(SPYRM[, list(DT, RV5, BPV5)]), testStats), type = "HARCJ")