Announcement

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

  • -gmm- syntax for instruments

    Hello forum members,

    I am estimating the following model:

    Code:
    ivpoisson gmm y x1 x2 x3 x4 (x5 = z1 z2 z3), additive
    where y(it) is an over-dispersed non-negative count, x1-x4(it) are exogenous, x5(it) is an endogenous binary predictor, and z1-z3(it) are instruments.

    Alternatively, to account for fixed effects in a panel model, I first use the code as suggested in Trivedi (2010) slide 54 (http://www.stata.com/meeting/mexico1...ug_trivedi.pdf):

    Code:
    program gmm_poi9
    version 13
    syntax varlist if, at(name) myrhs(varlist) mylhs(varlist) myidvar(varlist)
    quietly {
    tempvar mu mubar ybar
    gen double `mu' = 0 `if'
    local j=1
    foreach var of varlist `myrhs' {
    replace `mu' = `mu' + `var'*`at'[1,`j'] `if'
    local j = `j' + 1
    }
    replace `mu' = exp(`mu')
    egen double `mubar' = mean(`mu') `if', by(`myidvar')
    egen double `ybar' = mean(`mylhs') `if', by(`myidvar')
    replace `varlist' = `mylhs' - `mu'*`ybar'/`mubar' `if'
    }
    end
    And second, run the following as suggested in the example by Trivedi (2010) slide 55:

    Code:
    gmm gmm_poi9, mylhs(y) myrhs(x1 x2 x3 x4) myidvar(id) nequations(1) parameters(x1 x2 x3 x4) instruments (x1 x2 x3 x4), noconstant) onestep
    
    Step 1
    Iteration 0:   GMM criterion Q(b) =  3.011e+09  
    Iteration 1:   GMM criterion Q(b) =   77983166  
    Iteration 2:   GMM criterion Q(b) =  531272.52  
    Iteration 3:   GMM criterion Q(b) =  124.19557  
    Iteration 4:   GMM criterion Q(b) =   .0000135  
    Iteration 5:   GMM criterion Q(b) =  6.730e-18  
    
    GMM estimation
    
    Number of parameters =   4
    Number of moments    =   4
    Initial weight matrix: Unadjusted                     Number of obs  =    8553
    
    ------------------------------------------------------------------------------
                 |               Robust
                 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          x1|    .008391   .0005281    15.89   0.000      .007356    .0094261
          x2|   .0047405   .0016874     2.81   0.005     .0014333    .0080477
          x3|  -.0003832   .0002428    -1.58   0.115    -.0008591    .0000927
         x4 |   .4729073   .0646742     7.31   0.000     .3461482    .5996665
    ------------------------------------------------------------------------------
    Instruments for equation 1: x1 x2 x3 x4
    But obviously this is not the model that I intend to run (as specified above). When I try something like below, I get an error.

    Code:
    gmm gmm_poi9, mylhs(y) myrhs(x1 x2 x3 x4) myidvar(id) nequations(1) parameters(x5)
    instruments(z1 z2 z3, noconstant) onestep
    no non-missing values returned for equation 1 at initial values
    r(498);
    Please advise on how I should run -gmm- for the kind of model as specified in -ivpoisson- above.
    Last edited by Anton Ivanov; 12 Jul 2015, 22:02.

  • #2
    I can provide additional information if needed.

    Comment


    • #3
      So following example from (http://www.stata.com/stata11/gmm.html) I managed to run the following model (considering x5 is endogenous):

      Code:
      gmm gmm_poi9, mylhs(y) myrhs(x1 x2 x3 x5) myidvar(id) nequations(1) nparameters(4) instruments(
      > x1 x2 x3 z1 z2 z3, noconstant) nolog
      
      Final GMM criterion Q(b) =  2.17e-33
      
      GMM estimation
      
      Number of parameters =   4
      Number of moments    =   6
      Initial weight matrix: Unadjusted                     Number of obs  =    8553
      GMM weight matrix:     Robust
      
      ------------------------------------------------------------------------------
                   |               Robust
                   |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               /b1 |   .0086641   .0004681    18.51   0.000     .0077467    .0095815
               /b2 |   .0067711   .0018342     3.69   0.000     .0031762    .0103661
               /b3 |  -.0004026   .0002331    -1.73   0.084    -.0008595    .0000544
               /b5 |   .1918201   .1264306     1.52   0.129    -.0559793    .4396195
      ------------------------------------------------------------------------------
      Instruments for equation 1: x1 x2 x3 z1 z2 z3
      As far as I understand, the number of instruments shall not be less than the number of instruments. Please advise how I should specify that only x5 shall be instrumented and only with z1 z2 and z3?

      Comment


      • #4
        Dear Anton,

        Others in this forum are more qualified to help you with this, but I guess you are doing what you want.

        If we take 2SLS as an analogy, in the first stage you would regress x5 on x1 - x3 and on z1 - z3, so you do not really want x5 to be instrumented only by z1 - z3. Also, in 2SLS you can imagine that in the first stage you also regresses x1, x2, and x3 on x1 - x3 and on z1 - z3. Of course, in this case the fitted values will be identical to the dependent variable and therefore we do not really need to do this, but is shows that all regressors are actually instrumented. Now, in GMM there is no first stage as in 2SLS, but it is essentially the same idea: all regressors are instrumented by all instruments and these include the exogenous regressors. So, this looks fine to me.

        All the best,

        Joao

        Comment


        • #5
          Thank you sincerely for reply, Joao. Your explanation makes sense.
          Last edited by Anton Ivanov; 13 Jul 2015, 11:09.

          Comment


          • #6
            .
            Last edited by Anton Ivanov; 13 Jul 2015, 12:27.

            Comment


            • #7
              .
              Last edited by Anton Ivanov; 13 Jul 2015, 12:27.

              Comment


              • #8
                Dear Anton,

                I think you had another question, but you deleted it before I could reply; if I recall it correctly, you can do what you suggested. Actually we did that in the paper that introduced the method used by -ivpoisson- with the -additive- option. Please see the first two lines on page 291 of this paper.

                All the best,

                Joao

                Comment


                • #9
                  Hi Anton,

                  I don't think your moment condition is correct in your program for endogeneity. I think it should be:

                  Code:
                  replace `varlist' = `mylhs'/`mu' - L.`mylhs'/L.`mu' `if'

                  Comment

                  Working...
                  X