Announcement

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

  • Postestimation using first-stage coefficients in 2SLS

    Dear Stata experts,

    I would like to do some postestimation analysis of an IV regression using coefficients from both the first and second stages. Here is an example of what I have in mind:

    Code:
    sysuse auto, clear
    ivreg price turn (mpg = trunk)
    nlcom _b[turn]*_b[trunk]
    This does not work: "[trunk] not found". I tried using ivreg2 but without success. I'm using Stata/SE 14.2. Any help would be appreciated! Many thanks.

  • #2
    Mathieu:
    welcome to this forum.
    -ivreg- does not return the instrument as a coefficient:
    Code:
    . mat list e(b)
    
    e(b)[1,3]
               mpg        turn       _cons
    y1  -437.83886   -206.5232   23678.407
    
    . mat list e(V)
    
    symmetric e(V)[3,3]
                  mpg        turn       _cons
      mpg   87868.051
     turn   83104.526    83903.26
    _cons  -5166334.1  -5096552.7   3.122e+08
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      Thanks Carlo. It seems that -ivreg2- is able to store the first-stage coefficients using the "savefirst" option but I'm unable to access them through -nlcom-.

      Comment


      • #4
        The savefirst option of ivreg2 will store the estimates of the first stage regression, but you will need the estimates of the first stage and the reduced form together in the coefficient/variance-covariance matrix to use them in one expression with nlcom. The savesfirst option of ivreg2 does that.
        Code:
        sysuse auto, clear
        ivreg2 price turn (mpg = trunk), savesfirst
        estimates restore _ivreg2_sfirst_price
        mat list e(V)
        nlcom [price]_b[turn] * [mpg]_b[trunk]

        Comment


        • #5
          Thanks Wouter but I think I'm missing something. This does not seem to take the second stage coefficient for "turn" but the coefficient from "reg price trunk turn". I'm trying to combine the first-stage estimate of "_b[trunk]" with the second-stage coefficient for "_b[turn]". Maybe I'm misunderstanding something...

          Comment


          • #6

            [price]_b[turn] means the coefficient of turn from the regression where price is the dependent variable (second stage or reduced form). [mpg]_b[trunk] means the coefficient of trunk from the regression where mpg is the dependent variable, or first stage. I believe this is what you are looking for?
            Last edited by Wouter Wakker; 10 Nov 2020, 11:07. Reason: wrong wording

            Comment


            • #7
              Yes but I'm a bit confused by the number. If I just run the IV (ivreg2 price turn (mpg = trunk)) I get

              Code:
              ------------------------------------------------------------------------------
                     price |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                       mpg |  -437.8389   290.3547    -1.51   0.132    -1006.924    131.2458
                      turn |  -206.5232   283.7283    -0.73   0.467    -762.6205    349.5741
                     _cons |   23678.41   17307.36     1.37   0.171     -10243.4    57600.22
              ------------------------------------------------------------------------------
              If I run the first stage alone (reg mpg turn trunk), I get

              Code:
              ------------------------------------------------------------------------------
                       mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                      turn |  -.7610113   .1306893    -5.82   0.000    -1.021598   -.5004242
                     trunk |  -.3161825   .1344153    -2.35   0.021    -.5841989    -.048166
                     _cons |   55.82001    4.35419    12.82   0.000       47.138    64.50202
              ------------------------------------------------------------------------------
              So I would expect [price]_b[turn] * [mpg]_b[trunk] = -206.5232 * -.3161825 = 65.299021684. Instead when I run your code I get -40.05308.

              I get -40.05308 when instead of the IV I run a "fake" second-stage (reg price turn trunk) in which case the output is

              Code:
              ------------------------------------------------------------------------------
                     price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
              -------------+----------------------------------------------------------------
                      turn |   126.6771   93.30743     1.36   0.179    -59.37263    312.7268
                     trunk |    138.437   95.96765     1.44   0.154    -52.91708     329.791
                     _cons |  -761.7631   3108.734    -0.25   0.807    -6960.404    5436.877
              ------------------------------------------------------------------------------
              And so here [price]_b[turn] * [mpg]_b[trunk] = 126.6771* -.3161825 = -40.0530. But this is not using the coefficient from the second stage (where we should use the predicted value of mpg from the first-stage as a regressor).

              Sorry for the confusion, I might not have been clear in my question.

              Comment


              • #8
                You're right, the savesfirst option doesn't store the reduced form estimates but simply the results as they are in reg price turn trunk.
                Code:
                . sysuse auto, clear
                (1978 Automobile Data)
                
                . qui ivreg2 price turn (mpg = trunk), savesfirst
                
                . estimates replay _ivreg2_sfirst_price
                
                -----------------------------------------------------------------------------------------------------------------------------------
                Model _ivreg2_sfirst_price (System of first-stage/reduced form regressions)
                -----------------------------------------------------------------------------------------------------------------------------------
                
                System of first-stage/reduced-form regressions:
                -----------------------------------------------
                
                Statistics consistent for homoskedasticity only
                Number of obs =                     74
                ------------------------------------------------------------------------------
                             |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                price        |
                       trunk |    138.437   95.96765     1.44   0.154    -52.91708     329.791
                        turn |   126.6771   93.30743     1.36   0.179    -59.37263    312.7268
                       _cons |  -761.7631   3108.734    -0.25   0.807    -6960.404    5436.877
                -------------+----------------------------------------------------------------
                mpg          |
                       trunk |  -.3161825   .1344153    -2.35   0.021    -.5841989    -.048166
                        turn |  -.7610113   .1306893    -5.82   0.000    -1.021598   -.5004242
                       _cons |   55.82001    4.35419    12.82   0.000       47.138    64.50202
                ------------------------------------------------------------------------------
                
                . reg price trunk turn
                
                      Source |       SS           df       MS      Number of obs   =        74
                -------------+----------------------------------   F(2, 71)        =      4.91
                       Model |  77228695.2         2  38614347.6   Prob > F        =    0.0100
                    Residual |   557836701        71  7856854.94   R-squared       =    0.1216
                -------------+----------------------------------   Adj R-squared   =    0.0969
                       Total |   635065396        73  8699525.97   Root MSE        =      2803
                
                ------------------------------------------------------------------------------
                       price |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
                -------------+----------------------------------------------------------------
                       trunk |    138.437   95.96765     1.44   0.154    -52.91708     329.791
                        turn |   126.6771   93.30743     1.36   0.179    -59.37263    312.7268
                       _cons |  -761.7631   3108.734    -0.25   0.807    -6960.404    5436.877
                ------------------------------------------------------------------------------
                I don't know why this is, and my knowledge of IV estimation is not sufficient to suggest a fix, so I hope someone else can help.

                Comment


                • #9
                  Thank you for looking into this. I've read the ivreg2 documentation and it clearly states that "The savesfirst and savesfprefix(prefix) options work similarly for the sfirst option if the user wishes to save the first-stage and reduced form estimations as a single estimated system." So this is very confusing. Hopefully somebody else can shed light on what is going on.

                  Comment


                  • #10
                    See https://www.statalist.org/forums/for...-bug-in-ivreg2

                    Comment


                    • #11
                      Wouter Wakker stated above
                      You're right, the savesfirst option doesn't store the reduced form estimates but simply the results as they are in reg price turn trunk.
                      I repeat what I wrote in another thread: the first stage estimates the the regression of mpg on turn and trunki. The reduced form here obtained by regressing price and mpg on turn and trunk.
                      So ivreg2 produces what is says it will.
                      I haven't tried the solution proposed by Fernando Rios in the thread referred to by Andrew Musau in #10 above.

                      Comment


                      • #12
                        Eric de Souza Right, I guess I'm not sure of the official definition for "reduced for estimates". My understanding was that they were the estimates for the second stage regression but I might be wrong about this.

                        Comment


                        • #13
                          Mathieu Taschereau-Dumouchel : The first stage is the regression of the endogenous regressors on the instruments (included, that is, those that enter the equation for the model, and excluded, that is, those that do not enter the equation).
                          In the command:
                          Code:
                           ivreg2 price turn (mpg = trunk), savesfirst
                          the endogenous regressor is mpg, the included instrument is turn, and the excluded instrument is trunk.
                          The first stage is, therefore, regress mpg turn trunk
                          The second stage is the regression of price on turn and on the fitted value of mpg from the first stage.
                          Of course, to obtain correst standared errors in the second stage one cannot use regress because one of the regressors is a fitted (calculated) value.
                          This is why it is still not clear to me what exactly your ultimate aim is.

                          To be perfectly clear, I hope, when you issue the command
                          ivreg2 price turn (mpg = trunk)
                          the first stage is estimating the equation
                          Code:
                           mpg = b0 + b1*turn + b2*trunk
                          .
                          The second stage is estimating the equation
                          Code:
                           price = a0 + a1*turn + a2*mpgfit
                          where mpgfit is the fitted value of mpg from the first stage.

                          It is not clear to me what constraints you wish to impose.
                          Last edited by Eric de Souza; 12 Nov 2020, 13:28.

                          Comment

                          Working...
                          X