Learn R Programming

highfrequency (version 1.0.1)

rKernelCov: Realized kernel estimator

Description

Realized covariance calculation using a kernel estimator. The different types of kernels available can be found using listAvailableKernels.

Usage

rKernelCov(
  rData,
  cor = FALSE,
  alignBy = NULL,
  alignPeriod = NULL,
  makeReturns = FALSE,
  kernelType = "rectangular",
  kernelParam = 1,
  kernelDOFadj = TRUE,
  ...
)

Value

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.

Arguments

rData

an xts or data.table object containing returns or prices, possibly for multiple assets over multiple days

cor

boolean, in case it is TRUE, and the input data is multivariate, the correlation is returned instead of the covariance matrix. FALSE by default.

alignBy

character, indicating the time scale in which alignPeriod is expressed. Possible values are: "ticks", "secs", "seconds", "mins", "minutes", "hours"

alignPeriod

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".

makeReturns

boolean, should be TRUE when rData contains prices instead of returns. FALSE by default.

kernelType

Kernel name.

kernelParam

Kernel parameter.

kernelDOFadj

Kernel degree of freedom adjustment.

...

used internally, do not change.

Author

Scott Payseur, Onno Kleen, and Emil Sjoerup.

Details

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.

References

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.

See Also

ICov for a list of implemented estimators of the integrated covariance.

Examples

Run this code
# 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