## HY_cov(tx,ty,x,y,bl​ocksize,y_t_offset)

Version 1.0.0.0 (7.53 KB) by
Implements the Hayashi-Yoshida Covariance (2005) for the two asynchronous time series x,y

Updated 30 Jan 2017

[CHY,rHY] = HY_cov(tx,ty,x,y,blocksize,y_t_offset)
Implements the Hayashi-Yoshida Covariance (2005) for the two asynchronous time series x,y which are respectively sampled at times tx, ty.
Returns:
CHY, the Hayashi-Yoshida Covariance
rHY, "ro HY", the HY correlation coeffecient
Suggestions:
1) Make x,tx the lower sampled time history
2) Ensure the blocksize selection does not drop a significant portion of the time history.

This method estimates the "realized" covariance of the changes in x and y (del_x, del_y). This method relies on identifying time interval vectors, Iix and Ijy, which consist of the time ranges between each sampling of their respective vectors. x and y may have different sample counts and non-periodic sampling times. The interval vectors (Iix and Ijy) are used to build an indicator function II. II has a value of 1 when there is some overlap between del_x, del_y time intervals, but 0 when there is no overlap.
The HY Covariance is:
CHY = S_i,1:n[S_j,1:m[del_x(i)*del_y(j)*II(ti,tj)]]
where S_i,1:n is the summation operator over index i from 1 to n. It should be noted that even though this formula contains 2 summation operators, it is not using two operators in the same was as a cross correlation estimate would. That is because most x and y time intervals will not overlap, meaning II will be mostly 0 for i,j, which means nothing is being summed outside the overlapped window.
CHY gives the "contemporaneous" correlations. The literature cites work by "Hoffman et al. (2010)" to extend the estimator to allow for leads and y_t_offset, which is is comparable to a cross correlation estimate. This identifies y_t_offset in reference to the y vector.

### Cite As

Brian Liswell (2023). HY_cov(tx,ty,x,y,blocksize,y_t_offset) (https://www.mathworks.com/matlabcentral/fileexchange/61343-hy_cov-tx-ty-x-y-blocksize-y_t_offset), MATLAB Central File Exchange. Retrieved .

##### MATLAB Release Compatibility
Created with R2014a
Compatible with any release
##### Platform Compatibility
Windows macOS Linux
##### Categories
Find more on Correlation and Convolution in Help Center and MATLAB Answers