Announcement

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

  • Printing one estimation's stat on a table for a different estimation result, in -esttab-

    Hello,

    I am trying to make one table with the first stage of an IV and a second table with the 2SLS results. The first stage is run using -reg-, and the 2SLS is run with -ivreg2-. The test statistic in question is the Montiel-Pflueger (2013) effective F statistic, which is obtained by running the user-contributed -weakivtest- (which can be installed from SSC) after -ivreg2-, and calling the stored value r(F_eff). I am storing results and exporting Latex tables of the regression results with user-contributed commands -eststo- and -esttab- (available in -estout- from SSC).

    I would like to obtain the effective F stat from -weakivtest- after running the 2SLS in -ivreg2- and then print that effective F stat on the separate table I have for the first stage. How can I do this?

    Here is my attempt using the cars data as a toy example. This code results in printing the Effective F on the table for 2SLS, correctly, but it prints a blank space in the row for the Effective F stat on the table for the first stage, rather than printing the correct Effective F value:

    Code:
     sysuse auto
    ssc install estout
    ssc install weakivtest
     
    *first stage reg price weight, r
        eststo m1
     
    * 2SLS ivreg2 displacement (price=weight), r
      eststo m2
        weakivtest
      quietly estadd scalar weakf=r(F_eff), replace
     
    *save table for 2SLS esttab m2 using "cars_weakiv_2sls", ///
          replace booktabs label se star(* 0.10 ** 0.05 *** 0.01) ///
          s(weakf, ///
          label("Effective F")) ///
          substitute(_ \_ )
     
    ivreg2 displacement (price=weight), r
    weakivtest
      est restore m2 // bring back the first stage entry
      quietly estadd scalar weakf=r(F_eff), replace
        esttab m1 using "cars_weakiv_ols", ///
          replace booktabs label se star(* 0.10 ** 0.05 *** 0.01) ///
          s(weakf, ///
          label("Effective F")) ///
          substitute(_ \_ )

    Thanks in advance for your help!

  • #2
    Code:
     sysuse auto
    *ssc install estout
    *ssc install weakivtest
     
    
     
    ivreg2 displacement (price=weight), r
      eststo m2
        weakivtest
      quietly estadd scalar weakf=r(F_eff), replace
      local weakf=r(F_eff)
     
    *save table for 2SLS esttab m2 using "cars_weakiv_2sls", ///
          replace booktabs label se star(* 0.10 ** 0.05 *** 0.01) ///
          s(weakf, ///
          label("Effective F")) ///
          substitute(_ \_ )
     
       
    eststo m1: reg price weight, r
      quietly estadd scalar weakf=`weakf'
        esttab m1, ///
          replace  label se star(* 0.10 ** 0.05 *** 0.01) ///
          s(weakf, ///
          label("Effective F")) ///
          substitute(_ \_ )
    You do not need to run the first-stage regression separately. See #9 of the linked thread below.

    https://www.statalist.org/forums/for...eg2-by-outreg2

    Comment


    • #3
      That's a clever solution, thanks very much, Andrew! And thanks for pointing me to that feature for saving first-stage results as part of the 2SLS estimation -- that's handy.

      Comment

      Working...
      X