Announcement

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

  • Multiple pairwise VAR for Groups

    Hello,

    I have to admit that I am a fairly new Stata-user and I am sorry if answers for my questions are obvious. Furthermore, I am sorry for my bad english but I hope you can help me.
    Even though I know that it posting an image to explain the data is not the best way I have attached one because it makes it easier to explain my problem.
    As you can see I have time series data with different variables (Var1 ... ) and each variable belongs to a group (two digits).
    Now I would like to make a pairwise VAR for all variables of one group with all variables of another group.
    For example I would like to make a VAR wit Var1/Var2; Var1/Var3, Var4/Var2 and Var4/Var3 and the same vor Var7.
    I hope it is clear what I mean.

    My goal is to use the granger-causality test (vargranger after VAR estimation) to count the number of significant granger causalities between the groups. So for example I would like to know if there are 4 granger causal relations between group 10 and 11.

    So I am looking for a to calculate this automatically as I have a large number of variables.
    I think I would need a loop but as I am completely new in Stata I am not sure if it is possible at all.
    The commands in the loop would be something like:

    varbasic Var1 Var2, lags (1 2) nograph
    vargranger
    mat results12 = r(gstats)

    and afterwards I would generate a new variable like:
    generate granger_group1011_company12 = 1 if results[1,3] <= 0.05

    (of course the varibale has to be shorter but maybe somethink like this)

    I am very thankful if someone is able to help me with the loop. Furthermore I am not sure if the VAR-analysis works with the groups.
    If not maybe it is possible to make a pairwise VAR for every variable-pair and afterwards adjust for the grouping?

    As I said, I am very sorry to ask you so much but I am thankful for every hint. I do not expect a complete solutions but ideas would be great.
    Thank you so much.

    Christian
    Last edited by Christian Rose; 25 Sep 2014, 09:17.

  • #2
    Sorry for double-posting but I try to get some solutions of sub-problems in order to create a total solution.
    In order to get a pairwise granger-causility test I used the following: (I only tried it with 3 variables U1-U3 but in reality I have many more):

    Code:
    foreach j of varlist U1 U2 U3{
    foreach i of varlist U1 U2 U3{
      varbasic `j' `i', lags(1 2) nograph
      vargranger
      mat results = r(gstats)
      generate var_`j'_`i' if results[1,3] < 0.05
    }
    }
    It works kind of

    To improve my results I have a few questions at first:

    I am looking for an if-clause within the varbasic command sothat varbasic is not calculated if i=j. I have tried:
    Code:
    varbasic `j' `i' if `j' ~= `i', lags(1 2) nograph
    but it does not work. Do you have an idea?

    Is it possible to choose the optimal lag-length based on one criteria (lets say SIC) automatically within the loop?

    And for the end two statistical questions:

    If I am using:
    Code:
    varbasic U1 U2 U3, lags(1 2) nograph
    vargranger
    I get a pairwise granger-causality test and even though the granger causality test is pairwise I get different results than before. Why is that the case?

    And purely statistical: I have to make sure that my variables are stationary right? Is it possible to check for that within the loop?

    Thank you so much for your help

    Comment


    • #3
      I know essentially nothing about these tests, but some details here allow comment on the Stata code required.

      Code:
        
       varbasic `j' `i' if `j' ~= `i', lags(1 2) nograph
      That code says: carry out this command on those observations for which the values of the two variables are not the same. But when the variables concerned are one and the same, there are no such observations and that will presumably lead to an attempt to carry out the test, but then an error message that there are no observations. But the logic you want is quite different. You are saying, if the variables are not the same, then carry out the test. That requires an if command, not an if qualifier, and there is one comparison, on the variables' names, not on their values:

      Code:
      if "`j'" != "`i'" varbasic `j' `i',  lags(1 2) nograph
      You say that this generate command works, "kind of", but I am clear that the command will not work at all. Perhaps you reported something you didn't type.

      Code:
      generate var_`j'_`i' if results[1,3] < 0.05
      There is an overarching issue with what you are doing. You are carrying out numerous significance tests, which are not at all independent. That would worry many statistically-minded researchers, especially in terms of your interpretation of the entire procedure.

      I turn to some matters of form, to help with your writing this up and your future use of Statalist:

      1. Clive Granger was a great econometrician; his name should always be capitalised.
      2. One criterion, two criteria.
      3. We ask people here to use full real names.
      4. "doesn't work" is never informative; you should always say exactly what happens.

      The last two points are spelled out in the FAQ, which you were asked to read before posting.

      Comment


      • #4
        I am sorry if I have annoyed you or anyother user ot Statlist.
        My name is Christian Rose and I am sorry that I did not use my real name as user name. It is probably because I am not used to do that.
        Thank you for your kind reply.
        Your answer has helped me to solve the "if-problem".

        Sorry for the missing command in the generate-code. I used the following:

        Code:
         
         generate var_`j'_`i' = 1 if results[1,3] < 0.05
        I am not sure if I have understood this point:

        "There is an overarching issue with what you are doing. You are carrying out numerous significance tests, which are not at all independent. That would worry many statistically-minded researchers, especially in terms of your interpretation of the entire procedure."

        I am trying to measure the connectedness of variables based on Granger-causality. In detail I want to measure the "connectedness" / Granger-causality between different credit default swap spreads. I am not looking for the coefficients. I am only interested if CDS spread X Granger-causes CDS spread Y for different X and Y's.
        Why do you think is there an overarching issue? I would be very thankful if you could specify what you mean.

        Again, I am sorry for my lack of statistical knowledge but I am keen to learn.
        Thank you for your help.

        Comment


        • #5
          You shouldn't think that anyone is annoyed; rather, here as in any other forum worth joining, there is firm advice about what to do and what not to do. It's codified in the FAQ Advice. Some people, and I am one, play traffic cop here part-time.

          Using multiple tests always raises the question that the more tests you do the more likely it is that you get a rejection just by chance, even if all the null hypotheses are correct. So, in some way you are obliged to recognise that. It's harder to know how to do that when tests are mutually independent. Perhaps the most discussed variant of this problem is as the problem of multiple comparisons after something like analysis of variance. At a guess you are some kind of applied economist, and I am not, so off-hand I can't suggest good readings in your field.

          Comment

          Working...
          X