# interpretation of granger test outputs in R

I am using this R code:

library(lmtest)

grangertest(X ~ Y, order = 3, data = TS)

grangertest(Y ~ X, order = 3, data = TS)


I am getting these results:

Granger causality test

Model 1: X ~ Lags(X, 1:3) + Lags(Y, 1:3)
Model 2: X ~ Lags(X, 1:3)
Res.Df Df      F    Pr(>F)
1    637
2    640 -3 11.032 4.546e-07 ***
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
>
> grangertest(Y ~ X, order = 3, data = TS)
Granger causality test

Model 1: Y ~ Lags(Y, 1:3) + Lags(X, 1:3)
Model 2: Y ~ Lags(Y, 1:3)
Res.Df Df      F  Pr(>F)
1    637
2    640 -3 3.5013 0.01527 *
---
Signif. codes:  0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1


Could someone please help me to interpret the results? Let us say my level of significance is 0.05. It appears that I can reject the null hypothesis of no Granger causality. Does this meas that there is evidence that X and Y above are linked/influence each other? Is there any directionality? A nice blog about the granger test can be found here btw.

The answer is more or less already in the link you posted: The Granger Causality test fits a VAR model $$\begin{pmatrix} y_t\\ x_t \end{pmatrix}= \begin{pmatrix} \nu_y\\ \nu_x \end{pmatrix}+\begin{pmatrix} \alpha_{11,1}&\alpha_{12,1}\\ \alpha_{11,1}&\alpha_{12,1} \end{pmatrix}\begin{pmatrix} y_{t-1}\\ x_{t-1} \end{pmatrix}+... + \begin{pmatrix} \alpha_{11,p}&\alpha_{12,p}\\ \alpha_{11,p}&\alpha_{12,p} \end{pmatrix} \begin{pmatrix} y_{t-p}\\ x_{t-p} \end{pmatrix}+\begin{pmatrix} u_y\\ u_x \end{pmatrix}$$

and tests the NULL Hypothesis that X does NOT Granger cause Y, i.e. that the coefficients of the lags of X are not significant. $$H_0:\alpha_{12,i}=0 \text{ for } i=1,...,p$$

The p-value you get comes from a Wald test. If it is lower than your significance level (in this case 0.05) you can reject the NULL, so X Granger causes Y. To see whether there is also Granger causality in the other direction you'd have to perfom a Wald test to check if $\alpha_{11,i}=0\text{ for } i=1,...,p$. (which you did)
In your case both directions suggest Granger causality. The term causality is sometimes missleading, and could rather be thought as "predicatibility".
In your case: past values of x improve prediction of y (compared to only past values of y) and vice versa. There could also be a third variable z that influences both x and y.

Basically, if you see the first test, ( X ~ Lags(X, 1:3) + Lags(Y, 1:3) )you are proving if lags 1,2,3 of variable Y explain a X. Because you prove 3 coefficients, you use jont F test. The Pv is 4.546e-07, is under 0.05 then you can say that any Y lags explain X.

The second test have the same conclusion, in this case any X´lags explain Y.

Finally you have bidirectional causality.