Realized covariance estimator

69 views Asked by At

I want to estimate the covariance matrix using high-frequency data in Julia. I wish to start with using the realized covariance estimator. Thus, is there any available Julia code to estimate using rcov?

1

There are 1 answers

2
Colin T Bowers On

I don't think you need a package for this. Realized covariance is a very simple estimator. Let pmat denote a matrix of high-frequency prices, where columns correspond to assets, and rows correspond to the time-index. The high frequency returns can be obtained via:

rmat = log.(pmat[2:end,:] ./ pmat[1:end-1,:])

Note, you could speed up this computation by using a loop instead to avoid temporary allocations. Or as Oscar points out in the comments:

rmat = @views log.(pmat[2:end,:] ./ pmat[1:end-1,:])

will also reduce temporaries while preserving the neat one-liner.

Given rmat, the realized covariance estimator spanning the first to last time index is just:

realizedcov = rmat' * rmat