I am finding the Granger Causality between two channels. Then i call the function armorf with size of input 2xn (n:time points). The function gave me output matrix 2x2 of final prediction error E. Like this:

In the source code of Analyzing Neural Time Series Data [Matlab code for Chapter 28 - Figure 28.3], has two lines:

I guess that E(1, 1) is Exy, E(2, 2) is Eyx (please correct me if I am wrong). And how about E(1, 2) and E(2, 1)? Could you please explain the meaning of each element?
Thank you for your help.

Hi Kim. The matrix E is actually the covariance matrix of the errors. Here youâ€™re interested in the variances of the errors, which are on the diagonals. The off-diagonals are the covariances between the error terms of the two variables. I donâ€™t believe those have any uses in Granger causality (that I can think of at the moment).

I have a related question here. I noticed that in your code (Figure 28.5) when estimating the GP values in the frequency domain from bsmart toolbox, you used the covariances terms to get the corrected covariance.

% code below is adapted from bsmart toolbox function pwcausal.m
% corrected covariance
eyx = E(2,2) - E(1,2)^2/E(1,1);
exy = E(1,1) - E(2,1)^2/E(2,2);
N = size(E,1);

When should we correct for covariance and when should we not?

Hi Cheng. Interesting questions. I have to say, I donâ€™t know if there are situations where youâ€™d want to deviate from the standard GC equations. They go back several decades, so I trust that the current implementations are the way they are for good reason.

As for your second questionâ€¦ can you clarify which replacements youâ€™re suggesting or confused about? Iâ€™d have to take a dive back into the math and the code, but in general, I took the implementation from the bsmart toolbox.

Hi Mike,
Thanks for your reply.
For my first question, the reason I am asking is that I saw in Figure 28.3 the covariance was not corrected but in 28.5 it was. I wonder would there be different procedures when calculating the GP values in time and in the frequency domain.

For my second question, I am curious about it the S structure is the same as the E structure from armorf function. So here is what I am suggesting:
tf_granger(1,fi,timei) = log( abs(S(1,1))/abs(S(1,1)-(Hi(1,2)exy conj(Hi(1,2)))/EEG.srate) );