# The final prediction error E on armorf function

Dear all,

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?

Best Regards,
Kim Uyen.

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).

1 Like

Hi Mike,

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?

Another question from me is the S structure here:

tf_granger(1,fi,timei) = log( abs(S(2,2))/abs(S(2,2)-(Hi(2,1)exyconj(Hi(2,1)))/EEG.srate) );
tf_granger(2,fi,timei) = log( abs(S(1,1))/abs(S(1,1)-(Hi(1,2)eyxconj(Hi(1,2)))/EEG.srate) );

I wonder if we should use S(1,1) and S(1,2) to calculate the granger prediction from y to x?

Best regards,
Cheng

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,