Calculate the rMedRVar, defined in Andersen et al. (2012). Let \(r_{t,i}\) be a return (with \(i=1,\ldots,M\)) in period \(t\). Then, the rMedRVar is given by $$ \mbox{rMedRVar}_{t}=\frac{\pi}{6-4\sqrt{3}+\pi}\left(\frac{M}{M-2}\right) \sum_{i=2}^{M-1} \mbox{med}(|r_{t,i-1}|,|r_{t,i}|, |r_{t,i+1}|)^2 $$
rMedRVar(rData, alignBy = NULL, alignPeriod = NULL, makeReturns = FALSE, ...)
In case the input is an xts
object with data from one day, a numeric of the same length as the number of assets.
If the input data spans multiple days and is in xts
format, an xts
will be returned.
If the input data is a data.table
object, the function returns a data.table
with the same column names as the input data, containing the date and the realized measures.
an xts
or data.table
object containing returns or prices, possibly for multiple assets over multiple days
character, indicating the time scale in which alignPeriod
is expressed.
Possible values are: "ticks"
, "secs"
, "seconds"
, "mins"
, "minutes"
, "hours"
positive numeric, indicating the number of periods to aggregate over. For example, to aggregate
based on a 5-minute frequency, set alignPeriod = 5
and alignBy = "minutes"
.
boolean, should be TRUE
when rData
contains prices instead of returns. FALSE
by default.
used internally, do not change.
Jonathan Cornelissen, Kris Boudt, and Emil Sjoerup.
The rMedRVar belongs to the class of realized volatility measures in this package that use the series of high-frequency returns \(r_{t,i}\) of a day \(t\) to produce an ex post estimate of the realized volatility of that day \(t\). rMedRVar is designed to be robust to price jumps. The difference between RV and rMedRVar is an estimate of the realized jump variability. Disentangling the continuous and jump components in RV can lead to more precise volatility forecasts, as shown in Andersen et al. (2012)
Andersen, T. G., Dobrev, D., and Schaumburg, E. (2012). Jump-robust volatility estimation using nearest neighbor truncation. Journal of Econometrics, 169, 75-93.
IVar
for a list of implemented estimators of the integrated variance.
medrv <- rMedRVar(rData = sampleTData[, list(DT, PRICE)], alignBy = "minutes",
alignPeriod = 5, makeReturns = TRUE)
medrv
Run the code above in your browser using DataLab