Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Rolling window granger causality

    Hello everyone,

    I am trying to implement a rolling Granger causality test for several periods.

    Here is what I found as code from Mr Christopher F Baum's slides from: http://www.ncer.edu.au/events/docume...5S1.slides.pdf

    I quote:

    "We now present a second example of ado-file programming, motivated by a question from Stan Hurn. He wanted to compute Granger causality tests (vargranger) following VAR estimation in a rolling-window context. To implement this, I wrote program rgranger:"

    Code:
    . // program to do rolling granger causality test
    . capt prog drop rgranger
    . prog rgranger, rclass
    1. syntax varlist(min=2 numeric ts) [if] [in] [, Lags(integer 2)]
    2. var `varlist´ `if´ `in´, lags(1/`lags´)
    3. vargranger
    4. matrix stats = r(gstats)
    5. return scalar s2c = stats[3,3]
    6. return scalar s2i = stats[6,3]
    7. return scalar s2y = stats[9,3]
    8. end
    "We test the program to ensure that it returns the proper results: the p-values of the tests for each variable in the VAR, with the null hypothesis that they can appropriately be modeled as univariate
    autoregression. Inspection of the returned values from vargranger showed that they are available in the r(gstats) matrix. We can then invoke rolling to execute rgranger."


    Code:
    . // rolling window regressions
    . rolling pc = r(s2c) pi = r(s2i) py = r(s2y), window(35) saving(wald,replace) : ///
    > rgranger lconsumption linvestment lincome, lags(4)
    (running rgranger on estimation sample)

    But I can't get access to the data (database) to try to reproduce it to understand it more easily. However, I understood some elements of this code.

    But someone could explain me what the numbers in the scalars correspond to ?

    These numbers :
    Code:
    5. return scalar s2c = stats[3,3]
    6. return scalar s2i = stats[6,3]
    7. return scalar s2y = stats[9,3]
    And if I want to perform a granger test for only two variables instead of three, should I remove a scalar? And a variable in the following regression?

    Code:
     rolling pc = r(s2c) pi = r(s2i) py = r(s2y), window(35) saving(wald,replace) : ///

    Thanks in advance.

    Pita

  • #2
    NB: I tried to search the database here. But I don't have anything yet.

    https://www.stata-press.com/data/itsp2.html
    https://www.stata-press.com/data/


    Comment

    Working...
    X