Announcement

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

  • Estimating Granger causality for many variables.

    Hi. I have a list of 5 dependent variables (y1…y5) and a list of 5 independent variables (x1…x5).
    I want to test the causality from each ‘x’ to its corresponding ‘y’ by this command
    var y x, lags(1/3)
    vargranger
    and store the variable names and the related p-values in three new columns in this form
    y1 x1 p-value1
    y2 x2 p-value2
    and so on.
    Is it possible to do that in Stata?

  • #2
    Sure. Could use collect or store results in a matrix.

    matrix won't store names, but could use the number on y and x and then add those when you display the results of the matrix.

    Comment


    • #3
      I wrote this code to access the p-value. How can I make a list of p-values by adding the values in each step?
      Code:
      var y1 x1, lags(1/3)
      vargranger
       
      mata
      stats = st_matrix("r(gstats)")
      st_numscalar("pvalue", stats[2,3])
      end
      di pvalue

      Comment


      • #4
        Code:
        matrix R = J(5,2,.)
        forv i = 1/5 {
        qui var y`i' x`i', lags(1/3)
        qui vargranger
        matrix R[`i',1] = `i'
        matrix R[`i',2] = el(r(gstats),1,3)
        di "Model: y`i' <- x`i'   Prob = " %5.3f R[`i',2]
        }
        matrix list R

        Comment

        Working...
        X