|
||||||
Applied
Econometrics
Econ 508 - Fall 2007 e-Tutorial 8: Granger Causality |
||||||
![]() |
||||||
Welcome
to the eight issue of e-Tutorial. This issue focuses on time series models,
with special emphasis on the tests of Granger causality. I am providing
instructions for both R and STATA. I would like to remark that the theoretical
background given in class is essential to proceed with the computational
exercise below. Thus,
I recommend you to study Prof. Koenker's Lectures
Note 9 as you go through the tutorial.
The first thing you need is to download the data in text format by clicking here., or from the Econ 508 web site (Data). Save it in your preferred directory (I will save my as "C:/eggs.txt".) I suggest you to open the
file in Notepad (or another text editor) and type the name of the variable
"year" in the first row, first column, before "chic" "egg". Use <Tab>
to separate the names of variables. Save the file (I will save mine as
C:/eggs1.txt).
Inserting the Data in R: Next, you need to import
that data set to R, using the following commands:
It is useful to call the
time series package, and declare chickens and eggs as time series:
Inserting the Data in Stata: In Stata, you can type:
You will see that, because
I included variables names in the first row of the file egg1.txt, Stata
reads the first line of the data set as missing values. You should delete
this line (only!) on the Stata data editor window. Next you need to declare
your data as time series:
I. Granger Causulatity In the problem set 3 you will be asked to replicate the results of Thurman and Fisher's (1988), Table 1. I recommend you to sketch the Granger test, explain the NULL and the ALTERNATIVE hypotheses, and run the test for the causality for all lags, and both directions. At each round, collect the F-test statistics, p-values, and R-squares. At the end, please provide a table in the same format of Thurman and Fisher's (1988), containing your results, along with a graphical analysis. You have the option to run the Granger causality tests in in either R or Stata. In R: There is a code for the Granger test as follows: #Copy
from this point:
This code is available at http://www.econ.uiuc.edu/~econ472/routines.html., under the name granger.R. Your job is to copy the routine above and past it in the R console. (It's better to copy granger.R from the routines web page, because there the lines are not discontinuous...). This will create a function called "granger" that does the test for you. Next you should start running the Granger causality test for each of the lags and directions. For example, to test if chickens Granger cause eggs, using 1 lag, you type: granger(cbind(egg,chic),
L=1)
$p.val
$R2
and obsviously, to test in the reverse direction, you type: granger(cbind(chic,
egg), L=1)
$p.val
$R2
Do that for the for lags
1,2,3, and 4, and provide a table like Thurman and Fisher's (1988), containing
your
results, plus a graphical analysis.
In STATA: The first thing to do is to use the command summarize, detail or other functions presented in the previous tutorials, to obtain a description of the data. Once again, it is required that you show explicitly what are the NULL and ALTERNATIVE hypotheses of this test, and the regression equations you are going to run. The results of Thurman and Fisher's (1988), Table 1, can be easily replicated using OLS regressions and the time series commands introduced in the previous tutorials. A simple example in Stata: *Causality direction A: Do chickens Granger-cause eggs? For example, using the number of lags equals 1 you proceed as follows: regress egg L.egg L.chic
Source | SS
df MS
Number of obs = 53
------------------------------------------------------------------------------
And you can test if chickens Granger cause eggs using a F-test: test L.chic ( 1) L.chic = 0.0
F( 1, 50) = 0.05
**Causality direction B: Do eggs Granger-cause chickens? This involves the same techniques, but here you need to regress chickens against the lags of chickens and the lags of eggs. For example, using one lag you have: regress chic L.egg L.chic
Source | SS
df MS
Number of obs = 53
------------------------------------------------------------------------------
test L.egg ( 1) L.egg = 0.0
F( 1, 50) = 1.21
Are those numbers similar to those you have obtained using R? Do that for the for lags
1,2,3, and 4. Please provide a table in the same format of Thurman and
Fisher's (1988), containing your results, plus a graphical
analysis.
Causality in further lags: To test Granger causality in further lags, the procedures are the same. Just remember to test the joint hypothesis of non-significance of the "causality" terms. Example: Do eggs Granger cause chickens (in four lags)? regress chic L.egg L2.egg L3.egg L4.egg L.chic L2.chic L3.chic L4.chic
Source | SS
df MS
Number of obs = 50
------------------------------------------------------------------------------
and then test the joint significance of all lags of eggs test L.egg L2.egg L3.egg L4.egg (
1) L.egg = 0.0
F( 4, 41) = 4.26
The same result could be obtained in R: granger(cbind(chic,
egg), L=4)
$p.val
$R2
|
||||||
![]() |
Last update: September 25, 2007 |