Realized covariance calculation using a kernel estimator.
The different types of kernels available can be found using listAvailableKernels
.
rKernelCov(
rData,
cor = FALSE,
alignBy = NULL,
alignPeriod = NULL,
makeReturns = FALSE,
kernelType = "rectangular",
kernelParam = 1,
kernelDOFadj = TRUE,
...
)
in case the input is and contains data from one day, an \(N\) by \(N\) matrix is returned.
If the data is a univariate xts
object with multiple days, an xts
is returned.
If the data is multivariate and contains multiple days (xts
or data.table
), the function returns a list containing \(N\) by \(N\) matrices.
Each item in the list has a name which corresponds to the date for the matrix.
an xts
or data.table
object containing returns or prices, possibly for multiple assets over multiple days
boolean, in case it is TRUE
, and the input data is multivariate, the correlation is returned instead of the covariance matrix.
FALSE
by default.
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
to 5 and alignBy
to "minutes"
.
boolean, should be TRUE
when rData
contains prices instead of returns. FALSE
by default.
Kernel name.
Kernel parameter.
Kernel degree of freedom adjustment.
used internally, do not change.
Scott Payseur, Onno Kleen, and Emil Sjoerup.
Let \(r_{t,i}\) be \(N\) returns in period \(t\), \(i = 1, \ldots, N\). The returns or prices do not have to be equidistant. The kernel estimator for \(H = \code{kernelParam}\) is given by $$ \gamma_0 + 2 \sum_{h = 1}^H k \left(\frac{h-1}{H}\right) \gamma_h, $$ where \(k(x)\) is the chosen kernel function and $$ \gamma_h = \sum_{i = h}^N r_{t,i} \times r_{t,i-h} $$ is the empirical autocovariance function. The multivariate version employs the cross-covariances instead.
Barndorff-Nielsen, O. E., Hansen, P. R., Lunde, A., and Shephard, N. (2008). Designing realized kernels to measure the ex post variation of equity prices in the presence of noise. Econometrica, 76, 1481-1536.
Hansen, P. and Lunde, A. (2006). Realized variance and market microstructure noise. Journal of Business and Economic Statistics, 24, 127-218.
Zhou., B. (1996). High-frequency data and volatility in foreign-exchange rates. Journal of Business & Economic Statistics, 14, 45-52.
ICov
for a list of implemented estimators of the integrated covariance.
# Univariate:
rvKernel <- rKernelCov(rData = sampleTData[, list(DT, PRICE)], alignBy = "minutes",
alignPeriod = 5, makeReturns = TRUE)
rvKernel
# Multivariate:
rcKernel <- rKernelCov(rData = sampleOneMinuteData, makeReturns = TRUE)
rcKernel
Run the code above in your browser using DataLab