Granger Casuality

482 views
Skip to first unread message

Jieyun Fu

unread,
Jun 11, 2012, 10:52:48 AM6/11/12
to pystat...@googlegroups.com
Hi all, 

I am using the statsmodels.tsa.stattools.grangercausalitytests() method to test the Granger causality of two time series. I am not familiar with the original tsa package or the Granger causality theory itself. So I have to ask some dumb questions: 

1. I reverse the orders of X1 and X2, and I realized that the p-values are all 0.0000. In this case, should I conclude that X1 Granger causes X2 and X2 Granger causes X1. Is this statistically possible? 

2. What do these tests test individually? Particularly, for what regression expression? 

ssr based F test
ssr based chi2 test
likelihood ratio test
parameter F test

Thanks! I attached the output below: 

# test if series X2 granger causes series X1
ssr based F test:         F=92.2850 , p=0.0000  , df_denom=11246, df_num=1
ssr based chi2 test:   chi2=92.3096 , p=0.0000  , df=1
likelihood ratio test: chi2=91.9329 , p=0.0000  , df=1
parameter F test:         F=92.2850 , p=0.0000  , df_denom=11246, df_num=1

Granger Causality
number of lags (no zero) 2
ssr based F test:         F=50.1704 , p=0.0000  , df_denom=11243, df_num=2
ssr based chi2 test:   chi2=100.3853, p=0.0000  , df=2
likelihood ratio test: chi2=99.9400 , p=0.0000  , df=2
parameter F test:         F=50.1704 , p=0.0000  , df_denom=11243, df_num=2



# test if series X1 granger causes series X2
Granger Causality
number of lags (no zero) 1
ssr based F test:         F=51.0907 , p=0.0000  , df_denom=11246, df_num=1
ssr based chi2 test:   chi2=51.1043 , p=0.0000  , df=1
likelihood ratio test: chi2=50.9886 , p=0.0000  , df=1
parameter F test:         F=51.0907 , p=0.0000  , df_denom=11246, df_num=1

Granger Causality
number of lags (no zero) 2
ssr based F test:         F=25.4337 , p=0.0000  , df_denom=11243, df_num=2
ssr based chi2 test:   chi2=50.8901 , p=0.0000  , df=2
likelihood ratio test: chi2=50.7753 , p=0.0000  , df=2
parameter F test:         F=25.4337 , p=0.0000  , df_denom=11243, df_num=2

josef...@gmail.com

unread,
Jun 11, 2012, 11:41:23 AM6/11/12
to pystat...@googlegroups.com
On Mon, Jun 11, 2012 at 10:52 AM, Jieyun Fu <jiey...@gmail.com> wrote:
> Hi all,
>
> I am using the statsmodels.tsa.stattools.grangercausalitytests() method to
> test the Granger causality of two time series. I am not familiar with the
> original tsa package or the Granger causality theory itself. So I have to
> ask some dumb questions:
>
> 1. I reverse the orders of X1 and X2, and I realized that the p-values are
> all 0.0000. In this case, should I conclude that X1 Granger causes X2 and X2
> Granger causes X1.

I think so, I'm always getting confused which direction the test goes,
and the docstring might be wrong.
--
the source has this reference
http://support.sas.com/rnd/app/examples/ets/granger/index.htm
it looks to me the docstring goes the wrong way. Small p-value means
we reject the restricted model, which means the effect of the lagged
values of the other variable is statistically significant.

> Is this statistically possible?

Yes, if the feedback effect goes both ways, then lagged observations
or shocks of x2 affect (help predict) x1, and the other way around.

>
> 2. What do these tests test individually? Particularly, for what regression
> expression?
>
> ssr based F test
> ssr based chi2 test
> likelihood ratio test
> parameter F test

http://en.wikipedia.org/wiki/Granger_causality

They all test whether including lags of the other variable (additional
to own) lags is statistically significant.
It's basically a joint test that a group of parameters are all zero, in OLS.

When I wrote this initially, I didn't know which version of test is
commonly used, so I wrote 4 of them.
1 and 4 turn out to be the same and is what R reports (and is verified
against R, IIRC).

It's one of the tests where I couldn't make up my mind what the return
should be and I just return everything.
Statistical tests need a consistent return pattern/class, hopefully in
the 0.5 release
What frequency is your data? With more than 11000 observations you
could try increasing the lag length.

Josef

Jieyun Fu

unread,
Jun 11, 2012, 11:47:50 AM6/11/12
to pystat...@googlegroups.com
Thanks for your reply. 

More question: what's the difference between this statsmodels.tsa.stattools.grangercausalitytests() and statsmodels.tsa.vector_ar.var_model.VARResults.test_causality() ? 

Also, what's the difference between SSR based F test and parameter F test? I can't find a document that explains this two. 

Thanks again. 

josef...@gmail.com

unread,
Jun 11, 2012, 12:13:48 PM6/11/12
to pystat...@googlegroups.com
On Mon, Jun 11, 2012 at 11:47 AM, Jieyun Fu <jiey...@gmail.com> wrote:
> Thanks for your reply.
>
> More question: what's the difference between this
> statsmodels.tsa.stattools.grangercausalitytests()
> and statsmodels.tsa.vector_ar.var_model.VARResults.test_causality() ?

The main difference in the results comes from the degrees of freedom.
statsmodels.tsa.stattools.grangercausalitytests uses the degrees of
freedom definition for a single OLS estimate.
works only for bivariate case

VARResults.test_causality() uses the definition from the entire
system of equations.
There is a different definition of the test if more than two variables
are involved. I don't remember the details, but, IIRC, I once posted
an example and discussion of the difference to the mailing list.

(in R lmtest:grangertest is the same as
tsa.stattools.grangercausalitytests (SSR )
in R package VAR there is a similar version as the VAR causality test,
but with different definition if there are several variables involved)

>
> Also, what's the difference between SSR based F test and parameter F test? I
> can't find a document that explains this two.

The first one compares SSR between restricted and unrestricted model,
see the first definition of S1 in the SAS reference I gave.

The second builds a restriction matrix and uses the f_test of the
unrestricted results instance.

In the linear model these are either the same or close, in general
it's the difference between Wald, Likelihood Ratio and Lagrange
Multiplier tests.
(IIRC, the initial version of this was written as an example to check
that the different ways of calculating a test work.)
Asymptotically the are equivalent, but I never looked for a reference
whether there is a difference in power for granger causality tests in
finite samples.

Thanks for feedback and showing interest.
(There are functions that have accumulated over time and need a
review, mainly for usability and documentation. Knowing what users
want to use unearths at least some of them.)

Josef

josef...@gmail.com

unread,
Jun 11, 2012, 2:20:31 PM6/11/12
to pystat...@googlegroups.com
I just checked with Green Econometric Analysis again. He has the
Likelihood Ratio test as the main test in the explanation. But
mentioned that the LR tests relies on the normality assumption, while
the Wald tests (or GMM based) tests are more robust to different
distributional assumptions.

It would be better to call the test granger_non_causalitytest

Josef
Reply all
Reply to author
Forward
0 new messages