Can anyone help me calculating the average covariance of return?
1 view (last 30 days)
- Hi everyone. I'm trying to convert this formula into MatLab code:
Fcvc is a target matrix used for shrinking the sample covariance matrix of return towards their average variance and average covariance, in order to obtain a better estimator. The topic is fromt De Nard paper "Oops! I Shrunk the Sample Covariance Matrix Again: Blockbuster Meets Shrinkage"
I don't know how to compute the average covariance (average of off-diagonal entries of a simmetric matrix), can anyone help me?
William Rose on 27 Oct 2022
Edited: William Rose on 27 Oct 2022
[Edit: change the name of the initial matrix; it should not be Fcvc, it should be S. Add code to construct Fcvc using the which we calculate.]
You can just write a nested for loop (i,j) that does the calculation:
%Make a 4x4 covariance matrix
N=4; S=eye(N); %identity matrix
S=10*S %multiply by some arbitray constant
That looks like a reasonable covariance matrix: it is positive along the diagonal, and the absolute value of off-diagonal element are less than the diagoonal, and it is symmetric.
Now compute and :
Those values look reasonable.
Use siibar and sijbar to make Fcvc
That looks good.