rTSCov {highfrequency}R Documentation

Two time scale covariance estimation

Description

Calculate the two time scale covariance matrix proposed in Zhang et al. (2005) and Zhang (2010). By the use of two time scales, this covariance estimate is robust to microstructure noise and non-synchronic trading.

Usage

rTSCov(
  pData,
  cor = FALSE,
  K = 300,
  J = 1,
  KCov = NULL,
  JCov = NULL,
  KVar = NULL,
  JVar = NULL,
  makePsd = FALSE,
  ...
)

Arguments

pData

a list. Each list-item i contains an xts object with the intraday price data of stock ii for day tt.

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.

K

positive integer, slow time scale returns are computed on prices that are K steps apart.

J

positive integer, fast time scale returns are computed on prices that are J steps apart.

KCov

positive integer, for the extradiagonal covariance elements the slow time scale returns are computed on prices that are K steps apart.

JCov

positive integer, for the extradiagonal covariance elements the fast time scale returns are computed on prices that are J steps apart.

KVar

vector of positive integers, for the diagonal variance elements the slow time scale returns are computed on prices that are K steps apart.

JVar

vector of positive integers, for the diagonal variance elements the fast time scale returns are computed on prices that are J steps apart.

makePsd

boolean, in case it is TRUE, the positive definite version of rTSCov is returned. FALSE by default.

...

used internally, do not change.

Details

The rTSCov requires the tick-by-tick transaction prices. (Co)variances are then computed using log-returns calculated on a rolling basis on stock prices that are KK (slow time scale) and JJ (fast time scale) steps apart.

The diagonal elements of the rTSCov matrix are the variances, computed for log-price series XX with nn price observations at times τ1,τ2,,τn \tau_1,\tau_2,\ldots,\tau_n as follows:

(1nKnJ)1([X,X]T(K)nKnJ[X,X]T(J))(1-\frac{\overline{n}_K}{\overline{n}_J})^{-1}([X,X]_T^{(K)}- \frac{\overline{n}_K}{\overline{n}_J}[X,X]_T^{(J))}

where nK=(nK+1)/K\overline{n}_K=(n-K+1)/K, nJ=(nJ+1)/J\overline{n}_J=(n-J+1)/J and

[X,X]T(K)=1Ki=1nK+1(Xti+KXti)2.[X,X]_T^{(K)} =\frac{1}{K}\sum_{i=1}^{n-K+1}(X_{t_{i+K}}-X_{t_i})^2.

The extradiagonal elements of the rTSCov are the covariances. For their calculation, the data is first synchronized by the refresh time method proposed by Harris et al (1995). It uses the function refreshTime to collect first the so-called refresh times at which all assets have traded at least once since the last refresh time point. Suppose we have two log-price series: XX and YY. Let Γ={τ1,τ2,,τN\mboxT\mboxX} \Gamma =\{ \tau_1,\tau_2,\ldots,\tau_{N^{\mbox{\tiny X}}_{\mbox{\tiny T}}}\} and Θ={θ1,θ2,,θN\mboxT\mboxY}\Theta=\{\theta_1,\theta_2,\ldots,\theta_{N^{\mbox{\tiny Y}}_{\mbox{\tiny T}}}\} be the set of transaction times of these assets. The first refresh time corresponds to the first time at which both stocks have traded, i.e. ϕ1=max(τ1,θ1)\phi_1=\max(\tau_1,\theta_1). The subsequent refresh time is defined as the first time when both stocks have again traded, i.e. ϕj+1=max(τNϕj\mboxX+1,θNϕj\mboxY+1)\phi_{j+1}=\max(\tau_{N^{\mbox{\tiny{X}}}_{\phi_j}+1},\theta_{N^{\mbox{\tiny{Y}}}_{\phi_j}+1}). The complete refresh time sample grid is Φ={ϕ1,ϕ2,...,ϕMN+1}\Phi=\{\phi_1,\phi_2,...,\phi_{M_N+1}\}, where MNM_N is the total number of paired returns. The sampling points of asset XX and YY are defined to be ti=max{τΓ:τϕi}t_i=\max\{\tau\in\Gamma:\tau\leq \phi_i\} and si=max{θΘ:θϕi}s_i=\max\{\theta\in\Theta:\theta\leq \phi_i\}.

Given these refresh times, the covariance is computed as follows:

cN([X,Y]T(K)nKnJ[X,Y]T(J)), c_{N}( [X,Y]^{(K)}_T-\frac{\overline{n}_K}{\overline{n}_J}[X,Y]^{(J)}_T ),

where

[X,Y]T(K)=1Ki=1MNK+1(Xti+KXti)(Ysi+KYsi).[X,Y]^{(K)}_T =\frac{1}{K} \sum_{i=1}^{M_N-K+1} (X_{t_{i+K}}-X_{t_{i}})(Y_{s_{i+K}}-Y_{s_{i}}).

Unfortunately, the rTSCov is not always positive semidefinite. By setting the argument makePsd = TRUE, the function makePsd is used to return a positive semidefinite matrix. This function replaces the negative eigenvalues with zeroes.

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.

Author(s)

Jonathan Cornelissen, Kris Boudt, and Emil Sjoerup.

References

Harris, F., McInish, T., Shoesmith, G., and Wood, R. (1995). Cointegration, error correction, and price discovery on informationally linked security markets. Journal of Financial and Quantitative Analysis, 30, 563-581.

Zhang, L., Mykland, P. A., and Ait-Sahalia, Y. (2005). A tale of two time scales: Determining integrated volatility with noisy high-frequency data. Journal of the American Statistical Association, 100, 1394-1411.

Zhang, L. (2011). Estimating covariation: Epps effect, microstructure noise. Journal of Econometrics, 160, 33-47.

See Also

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

Examples


# Robust Realized two timescales Variance/Covariance
# Multivariate:
## Not run: 
library(xts)
set.seed(123)
start <- strptime("1970-01-01", format = "%Y-%m-%d", tz = "UTC")
timestamps <- start + seq(34200, 57600, length.out = 23401)

dat <- cbind(rnorm(23401) * sqrt(1/23401), rnorm(23401) * sqrt(1/23401))

dat <- exp(cumsum(xts(dat, timestamps)))
price1 <- dat[,1]
price2 <- dat[,2]
rcovts <- rTSCov(pData = list(price1, price2))
# Note: List of prices as input
rcovts

## End(Not run)


[Package highfrequency version 1.0.1 Index]