Announcement

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

  • Concerning Panel VAR (pvar.ado)

    Hello all,

    I'm have some quaestions about the pvar.ado package. It has been introduced by Inessa Love but before I turn to her I was wondering if some of you know solutions to my problems
    Browsing the Internet resp. Statalist was not successful.

    To come up with my dataset: I have a long balanced Panel (N=4, T=23) with yearly data, four endogenous variables and want to estimate a 1-lag PVAR.

    Now my questions:

    1) Everytime I use the monte [#] option to generate impulse response functions with error bands, they are indeed produced, but in an "old" graph format and not the common "live" format.
    Is there a way to convert the graph files into live format? Furthermore the graphs for the IRF's are not given in one big 4x4 stacked graph which would be better for graphical analysis. So I want to use the "graph combine" command which does not work for the old graph format.
    (Even this link did not help: http://www.ats.ucla.edu/stat/stata/faq/graphics78.htm)

    Furthermore I get the error message "option t1() incorrectly specified". I cannot find any reason why.

    2) Why do I have to time-demean the variables (as recommended in the help-file) before using the "helm" command for forward-demeaning? This just doesn't make sense to me.

    3) Maybe I did not understand the PVAR approach sufficiently, but why do we have to use lagged dependant variables (t-2) as instruments for the t-1 rhs-variables? The problem of the fixed effects in dynamic regression analysis should be solved with the forward-demeaning using "helm" shouldn't it? Couldn't we just use the variables in levels as in a normal VAR after eliminating the fixed effects?

    Thank you very much in advance!

    Tim Grünebaum

  • #2
    You don't say where (your version of) pvar comes from, or helm for that matter, but

    0. I don't think I've ever seen any version of this program. I don't know the author.

    1. There is a long history of people asking about this program on Statalist, although my rough memory is that most questions were never answered.

    2. If the program was written for version 7 (or earlier) then its graph commands are quite alien to current graphics commands. I'd need to see the graphics code to comment more but rewriting the graphics commands for current Statas could be anything from a few minutes' work to something less manageable to any user-programmer who remembers the old graphics or looks at help graph7.

    3. As you don't give any exact examples of the code you specified, I don't see how anyone can comment on your problem with the t1() option.

    4. No comments from me on any other aspects of pvar.

    Incidentally, I don't think it's an absolute that a program author bears responsibility for supporting their code indefinitely.
    Last edited by Nick Cox; 28 Aug 2014, 09:54.

    Comment


    • #3
      This seems to be a source of the program. I don't know if it is the most up to date or not.

      http://econ.worldbank.org/WBSITE/EXT...469382,00.html
      -------------------------------------------
      Richard Williams, Notre Dame Dept of Sociology
      StataNow Version: 19.5 MP (2 processor)

      EMAIL: [email protected]
      WWW: https://www3.nd.edu/~rwilliam

      Comment


      • #4
        Hey there,

        thank you for the quick reply.


        @ Nick: You are right, this program has not drawn much attention on Statalist. Executing a Panel VAR does not need much code, but here is what I did:

        - time-demean the vaiables, by hand in excel --> still I don't know why that makes sense!
        - load the variables, level and demeaned ones
        - make it a panel (xtset country year)
        - helmert decompose ( which is to forward-demean) the already time-demeaned variables as recommended for the pvar program (helm [varlist])
        - execute PVAR for the variables in levels (pvar [varlist], lag(1) gmm monte 500)

        Hare you can find a quite good explanation of the program:
        https://github.com/gaulinmp/accounti...STATA/pvar.ado

        @ Richard: Yes, this version seems a bit more up to date than mine...

        ...but still the graphics are in the old format. The program was first used in I. Love's 2006 Paper which is long after Stata 8 came out, but in the link above it is stated that the code was first written in 2000 and probably never updated to the post-Stata7 live format for graphs. As I am not yet an expert in writing codes I will not try to reconstruct the code to fit new graph commands. I will thus try to handle the graphics "by hand" which should work somehow

        Comment


        • #5
          Thanks for the GitHub reference. The code is version 6, which explains why the graph commands work at all.

          Warnings:

          1. Untested code.

          2. Keep a safe copy of the original program.

          Looking at the graph commands

          Code:
           
          gr ${name`j'}_5 ${name`j'} ${name`j'}_95 s if varname=="${name`g'}",saving(gr`g'_`j',replace) s(iii) c(lll) yli(0)  b1("response of ${name`g'} to ${name`j'} shock")
          looks as if it would go better as

          Code:
           
          line ${name`j'}_5 ${name`j'} ${name`j'}_95 s if varname=="${name`g'}", name(gr`g'_`j',replace) yli(0) b1("response of ${name`g'} to ${name`j'} shock")
          Code:
           
          gr ${name`j'} s if varname=="${name`g'}",saving(gr`g'_`j',replace) s(i) c(l) yli(0) b1("response of ${name`g'} to ${name`j'} shock")
          maps to

          Code:
           
          line ${name`j'} s if varname=="${name`g'}",name(gr`g'_`j',replace) yli(0) b1("response of ${name`g'} to ${name`j'} shock")
          and

          Code:
          gr using `grlist', t1(     Impulse-responses for $P lag VAR of $names ) `t2' `b2'
          
          gr using `grlist', t1( $P lag VAR of $names ) `t2' `b2'
          should then be

          Code:
           
          graph combine `grlist', t1(     Impulse-responses for $P lag VAR of $names ) `t2' `b2'
          
          graph combine `grlist', t1( $P lag VAR of $names ) `t2' `b2'




          Comment


          • #6
            Hello all,

            My answer may be late, but in the case of your problem is not solved...

            1)You can use the PVAR2 command from Ryan Decker (http://www.rdecker.net/code). It permits to make better graph, and you can choose more parameters than with Inessa Love's command.

            2)I think you have to time-demeaned the variables in order to take into account temporal heterogenity and "drop" it (because the dynamic in PVAR is assumed to be fully homogenous across cross-sectional units)

            3)
            a.PVAR command uses GMM estimators
            b. The problem of fixed effects is solved by using helmert transformation
            c. You can use the variables in level or in difference, but you have to note that there are helmert transformations that are used is the estimation
            (I wish I understood your last question...)

            Good luck
            MP

            Comment


            • #7
              Time-demeaning should be completely irrelevant because the Helmert (forward-orthogonal) transformation removes all time-invariant components, and the time-mean is such a time-invariant component.
              https://www.kripfganz.de/stata/

              Comment


              • #8
                Hi all,

                I would like to tag on an additional question on this topic. @Marie, thank you for posting the updated version of the code and thank you everyone for the help!

                By any chance, once the model is set up, does anybody know what commands would have to be run in order to forecast each of the variables into the future? For instance, say we have 3 variables, and we have data for t=1-100 for all 3 variables for panels 1-9 (out of 10 total panels). For the tenth panel, let's say we only have data for t=1-50 and for all 3 variables. If we then want to use the data (of all 3 vars) from all the time periods (t=1-100) of all the other panels (1-9) as well as data from t=1-50 of panel 10 (all 3 vars) to estimate what the future values would be for panel 10 for t=51-100 (for all 3 vars), how might we execute this forecasting in stata to receive our predicted values?

                Thank you again for the help.

                Comment


                • #9
                  I am completely new to STATA but wanted to give this pvar analysis a shot. How am I to introduce my variables and am I suppose to create my own varlist? Also, is there a particular order in which you are to run the three .ado files mentioned in PVAR2 (from Ryan Decker) command? Thanks for any help.

                  Comment


                  • #10
                    More particularly, I believe I am making a mistake in regards to this step:

                    * TO USE : must define global lists with all variables in equations
                    * dep.variables must be in lists y1 y2...
                    * regressors must be in x1 x2 ... and instruments in z1 z2 ...
                    * must define global macro G which has number of equations
                    * for example :
                    * global y1="ik" /* EQ 1: dep.var */
                    * global x1="const l.ik sk" /* EQ 1: rhs variables */
                    * global z1="const l.ik l.sk l2.ik l2.sk" /* EQ 1: instruments (include exog vars here) */
                    * global G=1

                    And, as a result, I am getting this error message:

                    . pvar2 y1 y2 y3 y4 y5 y6 y7, lag(1) gmm monte 500 12 2 decomp 30 5
                    panel variable: id (unbalanced)
                    time variable: year, 20010331 to 20101231, but with gaps
                    delta: 1 unit
                    GMM started : 14:47:39
                    accumulating matrices equation 1,no observations
                    r(2000);

                    Perhaps my mistake is obvious to someone; unfortunately it is not for me.

                    Comment


                    • #11
                      There is an updated version of pvar by Inessa Love available at:

                      https://sites.google.com/a/hawaii.ed.../home/research

                      NEW VERSION: Package of programs to estimate panel VAR
                      New in this version:
                      - updated to Stata 12
                      - uses built-in Stata's gmm program that allows for expanded functionality (eg. clustered errors, choice of the weighting matrix)
                      - added sub-routines for lag selection and granger causality
                      - can add exogenous variables
                      - new graphing capabilities compatible with Stata's var package
                      - see help files for details.
                      - use README.do to see how the PVAR package compares with Stata's build-in VAR package.

                      Comment


                      • #12
                        I suppose the issue with my unbalanced panel. In the newer version, I get the error message: "Cannot have fewer observations than parameters."

                        Comment


                        • #13
                          I do not understand your code completely, but the new error message might be the key.
                          Remind that the pvar estimates quite a few parameters, including fixed effects. And you lose observationd due to the "helm" procedure.
                          A long panel (large T) is needed to get appropriate estimates. In a short panel (large N) you have to estimate N fixed effects parameters using T observations for each.
                          This is just a conjecture and not based on complete understanding of your code ;-)

                          I am also using the new PVAR2 package now, thanks for that hint!

                          One more question:
                          In time series analysis we wish to have stationary series. If our aeries are not stationary, we "make then" stationary by e.g. differencing or using some kind of filter (like Hodrick Prescott). The helmert decomposition does not remove the trend sufficiently.
                          This is to my understanding what we cannot do in the panel VAR case as differencing eliminates the fixed effects as explained in the standard panel VAR literatur (see above).
                          Do you have any idea what options we have if we have non-stationary data?
                          Last edited by Tim Grünebaum; 15 Nov 2014, 07:25.

                          Comment


                          • #14
                            Is there any "sample" data somewhere online or which someone could contribute ... which could be used to test and to run either the pvar.ado or pvar2.ado code?

                            Thanks,
                            Kenneth Erickson
                            New Member
                            (and fairly long-time Stata user)

                            Comment


                            • #15
                              The site cited in #11 doesn't contain the .dta file used as an example in the help for pvar2. I got that far and gave up. You could try emailing the author or just try it out with your own data. (I've never used any of these programs.)

                              Comment

                              Working...
                              X