Announcement

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

  • Accessing Results from GMM estimation in other lines of code

    If I were to run a linear regression, say

    Code:
    reg lyi lki lli, robust
    then I could access the coefficients in future lines of code with
    Code:
    _b[lki]
    or
    Code:
     _b[lli]
    .

    is there a succinct way to obtain the same for specific coefficients from a GMM regression? I understand that the coefficients are somehow stored in e(b) but

    Code:
    disp e(b)
    
    disp e(b)[1]
    
    disp e(b){rho}
    all result in a type mismatch. The gmm estimation function I am using looks like this:

    Code:
    gmm (ly - ( {rho}*lly + {beta0} + {betak}*(lk - {rho}*llk) + {betal}*(ll - {rho}*lll) ) ), instruments(lk llk lll logwag loglwag) nolog
    I want this so I can plug the labor elasticity from the GMM into a function to estimate markups.

    Thanks in advance for your help!

  • #2
    Perhaps this can work:

    Code:
    gmm (ly - ( {rho}*lly + {beta0} + {betak}*(lk - {rho}*llk) + {betal}*(ll - {rho}*lll) ) ), instruments(lk llk lll logwag loglwag) nolog coeflegend
    But then the results are removed.

    Comment


    • #3
      There is nothing special about gmm in terms of its operation as an estimation command. The coefficients can be accessed in the usual way.

      Code:
      sysuse auto, clear
      gmm (mpg - {b1}*gear_ratio - {b2}*turn - {b0}), instruments(gear_ratio turn)
      di _b[/b1]
      mat l e(b)
      di e(b)["y1", "b2:_cons"]
      Res.:

      Code:
      . gmm (mpg - {b1}*gear_ratio - {b2}*turn - {b0}), instruments(gear_ratio turn)
      
      Step 1
      Iteration 0:  GMM criterion Q(b) =  471.67875  
      Iteration 1:  GMM criterion Q(b) =  3.058e-21  
      Iteration 2:  GMM criterion Q(b) =  2.545e-31  
      
      Step 2
      Iteration 0:  GMM criterion Q(b) =  1.691e-32  
      Iteration 1:  GMM criterion Q(b) =  1.691e-32  (backed up)
      
      note: model is exactly identified.
      
      GMM estimation 
      
      Number of parameters =   3
      Number of moments    =   3
      Initial weight matrix: Unadjusted                 Number of obs   =         74
      GMM weight matrix:     Robust
      
      ------------------------------------------------------------------------------
                   |               Robust
                   | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
               /b1 |   3.032884   1.501664     2.02   0.043     .0896757    5.976092
               /b2 |  -.7330502    .117972    -6.21   0.000    -.9642711   -.5018293
               /b0 |   41.21801   8.396739     4.91   0.000     24.76071    57.67532
      ------------------------------------------------------------------------------
      Instruments for equation 1: gear_ratio turn _cons
      
      . 
      . di _b[/b1]
      3.0328836
      
      . 
      . mat l e(b)
      
      e(b)[1,3]
                  b1:         b2:         b0:
               _cons       _cons       _cons
      y1   3.0328836  -.73305019   41.218012
      
      . 
      . di e(b)["y1", "b2:_cons"]
      -.73305019
      
      .
      For extracting elements from a matrix:

      Code:
      help matrix_extraction

      Comment


      • #4
        This is exactly what I was looking for here. Thank you for the help, Andrew.


        Originally posted by Andrew Musau View Post
        There is nothing special about gmm in terms of its operation as an estimation command. The coefficients can be accessed in the usual way.

        Code:
        sysuse auto, clear
        gmm (mpg - {b1}*gear_ratio - {b2}*turn - {b0}), instruments(gear_ratio turn)
        di _b[/b1]
        mat l e(b)
        di e(b)["y1", "b2:_cons"]
        Res.:

        Code:
        . gmm (mpg - {b1}*gear_ratio - {b2}*turn - {b0}), instruments(gear_ratio turn)
        
        Step 1
        Iteration 0: GMM criterion Q(b) = 471.67875
        Iteration 1: GMM criterion Q(b) = 3.058e-21
        Iteration 2: GMM criterion Q(b) = 2.545e-31
        
        Step 2
        Iteration 0: GMM criterion Q(b) = 1.691e-32
        Iteration 1: GMM criterion Q(b) = 1.691e-32 (backed up)
        
        note: model is exactly identified.
        
        GMM estimation
        
        Number of parameters = 3
        Number of moments = 3
        Initial weight matrix: Unadjusted Number of obs = 74
        GMM weight matrix: Robust
        
        ------------------------------------------------------------------------------
        | Robust
        | Coefficient std. err. z P>|z| [95% conf. interval]
        -------------+----------------------------------------------------------------
        /b1 |  3.032884  1.501664 2.02 0.043 .0896757 5.976092
        /b2 | -.7330502 .117972 -6.21 0.000 -.9642711 -.5018293
        /b0 | 41.21801 8.396739 4.91 0.000 24.76071 57.67532
        ------------------------------------------------------------------------------
        Instruments for equation 1: gear_ratio turn _cons
        
        .
        . di _b[/b1]
        3.0328836
        
        .
        . mat l e(b)
        
        e(b)[1,3]
        b1: b2: b0:
        _cons _cons _cons
        y1 3.0328836 -.73305019 41.218012
        
        .
        . di e(b)["y1", "b2:_cons"]
        -.73305019
        
        .
        For extracting elements from a matrix:

        Code:
        help matrix_extraction

        Comment

        Working...
        X