rTSCov: Two time scale covariance estimation

Description Usage Arguments Details Value Author(s) References Examples

Description

Function returns 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

1
2
rTSCov(pdata, cor=FALSE, K = 300 , J = 1,  K_cov = NULL , J_cov = NULL,
    K_var = NULL , J_var = NULL, makePsd = FALSE);

Arguments

pdata

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

cor

boolean, in case it is TRUE, the correlation is returned. 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.

K_cov

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

J_cov

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

K_var

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

J_var

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.

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 K (slow time scale) and J (fast time scale) steps apart.

The diagonal elements of the rTSCov matrix are the variances, computed for log-price series X with n price observations at times τ_1,τ_2,…,τ_n as follows:

(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 \overline{n}_K=(n-K+1)/K, \overline{n}_J=(n-J+1)/J and

[X,X]_T^{(K)} =\frac{1}{K}∑_{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: X and Y. Let Γ =\{ τ_1,τ_2,…,τ_{N^{\mbox{\tiny X}}_{\mbox{\tiny T}}}\} and Θ=\{θ_1,θ_2,…,θ_{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). The subsequent refresh time is defined as the first time when both stocks have again traded, i.e. φ_{j+1}=\max(τ_{N^{\mbox{\tiny{X}}}_{φ_j}+1},θ_{N^{\mbox{\tiny{Y}}}_{φ_j}+1}). The complete refresh time sample grid is Φ=\{φ_1,φ_2,...,φ_{M_N+1}\}, where M_N is the total number of paired returns. The sampling points of asset X and Y are defined to be t_i=\max\{τ\inΓ:τ≤q φ_i\} and s_i=\max\{θ\inΘ:θ≤q φ_i\}.

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

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

where

[X,Y]^{(K)}_T =\frac{1}{K} ∑_{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

an N x N matrix

Author(s)

Jonathan Cornelissen and Kris Boudt

References

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

Zhang, L., P. A. Mykland, and Y. Ait-Sahalia (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.

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
 # Robust Realized two timescales Variance/Covariance for CTS 
 data(sample_tdata); 
 data(lltc.xts); 
 data(sbux.xts); 
 
 # Univariate: 
 rvTS = rTSCov( pdata = sample_tdata$PRICE); 
 # Note: Prices as input
 rvTS 
 
 # Multivariate:
 rcTS = rTSCov( pdata = list(cumsum(lltc.xts)+100,cumsum(sbux.xts)+100) ); 
 # Note: List of prices as input
 rcTS 

Example output

Loading required package: xts
Loading required package: zoo

Attaching package: 'zoo'

The following objects are masked from 'package:base':

    as.Date, as.Date.numeric

[1] 0.0005276875
             [,1]         [,2]
[1,] 5.998720e-08 5.704123e-08
[2,] 5.704123e-08 6.854694e-08

highfrequency documentation built on May 2, 2019, 6:09 p.m.