Announcement

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

  • Finding the _b[coefficient] from the first-stage of ivreg2

    Dear all,

    I am trying to figure out how we can refer to a specific coefficient from the first-stage of ivreg2.

    In particular, I am interested in the coefficient from the instrumental variable (for the case of one IV and one endogenous variable).

    Consider, for example, running the following

    sysuse auto
    ivreg2 price (mpg = weight), first

    If we want to recover the coefficient of 'mpg' from the second-stage, we can just run

    di _b[mpg]

    My point is how to recover the _b[weight] from the first-stage?

    I know that we can recover, for example, the F-stat from the first stage by running

    di e(first)[4,1]

    So I was wondering whether we can recover the coefficient of _b[weight] in a similar fashion (instead of using 'savefirst' option or the 'est store').

    Thank you!

    Best regards,

    Otavio



  • #2
    ivreg2 is from SSC (FAQ Advice #12).

    If we want to recover the coefficient of 'mpg' from the second-stage, we can just run

    di _b[mpg]
    Obviously, the coefficient is coming from some default saved result.

    So I was wondering whether we can recover the coefficient of _b[weight] in a similar fashion (instead of using 'savefirst' option or the 'est store').
    The authors of the command have explicitly made it clear that if you want to save the result from the first-stage, you must use the -savefirst- option.

    The savefirst option requests that the individual first-stage regressions be saved for later access using the estimates command. If saved, they can also be displayed using first or ffirst and the ivreg2 replay syntax. The regressions are saved with the prefix "_ivreg2_", unless the user specifies an alternative prefix with the savefprefix(prefix) option. 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.
    The default therefore is not to save these results.


    Comment


    • #3
      Thank you Andrew Musau ,

      So your point is to run

      sysuse auto
      ivreg2 price (mpg = weight), first savefirst

      But how can we recover the coefficients using something like

      di _ivreg2_b[weight] ?

      Do you have any suggestion?

      Thank you very much!


      Comment


      • #4
        Valid for Stata 16+. With an earlier version, store r(table) as a regular Stata matrix and refer to that matrix.

        Code:
        sysuse auto
        ivreg2 price (mpg = weight), first savefirst
        estimates replay _ivreg2_mpg
        di r(table)["b", "weight"]
        mat l r(table)
        Res.:

        Code:
        . estimates replay _ivreg2_mpg
        
        ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        active results
        ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
        
        First-stage regression of mpg:
        
        Statistics consistent for homoskedasticity only
        Number of obs =                     74
        ------------------------------------------------------------------------------
                 mpg |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
              weight |  -.0060087   .0005179   -11.60   0.000    -.0070411   -.0049763
               _cons |   39.44028   1.614003    24.44   0.000     36.22283    42.65774
        ------------------------------------------------------------------------------
        
        . 
        . di r(table)["b", "weight"]
        -.00600869
        
        . 
        . mat l r(table)
        
        r(table)[9,2]
                    weight       _cons
             b  -.00600869   39.440284
            se   .00051788   1.6140031
             t   -11.60251   24.436312
        pvalue   3.798e-18   1.385e-36
            ll  -.00704106   36.222827
            ul  -.00497632    42.65774
            df          72          72
          crit   1.9934636   1.9934636
         eform           0           0
        
        .

        Comment


        • #5
          Thank you so much, Andrew Musau !! That is exactly what I was looking for! It works like a charm!

          Comment

          Working...
          X