# How to run a Granger Causality Test with Stata

I'm doing a study on the determinants of FDI (Foreign Direct Investment) in the ASEAN countries. Before doing a panel data analysis, I'd like to run a Granger Causality Test between the potential FDI determinants time series (GDP, exchange rate, ecc.) and the FDI's one to support the choice of these variables for the above panel analysis.

My questions are:

• Does it make sense?
• If the time series are non-stationary (I've already discovered it with a ADF test) could I (in any case) run the Granger CT or should I have to make time series stationary with some cointegration process before? (and in this case, which one?)
• (the most important) How can I do it with Stata? (I think I have to run a VAR or SVAR before doing the Granger CT, is it correct? does it make sense in non-stationary (unit root) time series?) how should I set up the test? (dependent variable, lag periods, ecc.)
• (and finally) How can I interpret the (Stata Granger CT) results?

• To Gabriele Pelli, Were you able to follow the answer? I am doing same test for two variables (FDI and GDP), but could not understand!
– user36493
Dec 21, 2013 at 9:10
• Dumitrescu/Hurlin (2012) give an extension of the Granger test to panel data. An implementation for Stata is in the package xtgcause, and implementation for R is the function pgrangertest in package plm. Feb 20, 2018 at 21:03
• you need to use impulse responses fuctions if you are to interpret May 20, 2018 at 22:12

I am by far no expert on time-series but these are my thoughts for what it is worth. Hopefully someone else could add to this to help you further on your way.

Does it make sense?

To me it doesn't really make a lot of sense. When I do panel data analysis I base the choice of my variables on the results in the literature. There should be a theoretical basis for your model.

I would just use the Granger causality test as a method of analysis. This paper might be of interest of you, where they use a Granger test in a panel data setting.

If the time series are non-stationary could I run the Granger CT or should I have to make time series stationary with some cointegration process before?

Yes you should make the time-series stationary as the VAR-model that you use to do the test assumes that the data is stationary. If your time-series has a unit root, often first differencing will eliminate this unit root.

How can I do it with Stata?

First differencing can be done by using the D-command (don't forget to time-set your data first)

So if you have your time-series called gdp then you first difference it by:

gen gdpdiff=D.gdp


You can set up the VAR model by using the var-command. For help on this simply type

help var


So the command for your VAR-model could be:

var fdi gdpdiff


Use varsoc to test the optimal length of the number of lags that need to be included. So in the command below I test the first 20 lags.

varsoc, lag(20)


The run your model with the desired number of lags, for instance

var fdi gdpdiff, lag(1/10)


After fitting the var-model you can do the Granger causality test using:

vargranger


How can I interpret the results?

I found this post quite useful on how to conduct and interpret a Granger causality test (it is done in R). Be aware that the null hypothesis is one on non Granger causality.