Announcement

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

  • outreg2 for ivreghdfe

    Dear Statalists,

    I am quite new to reghdfe and ivreghdfe. I hope someone can help me with my code.
    I have a panel data with 800 firms of 40 industries in 10 years.

    I want to run 2sls, z directly affects x, but indirectly affects y.

    Code:
    xtset firm year
    
    ivreghdfe y (x = z) $controls, absorb(industry year) first
    outreg2 using myfile.xls, replace stats(coef pval)

    But I could not obtain both the 1st stage and 2nd stage results with outreg2. I have tried to search here, but there is no suggestion to use outreg2 for ivreghdfe.
    Can anyone help me with this, please? I really appreciate your help.

    Regards,
    Ken

  • #2
    You may need to estimate the first stage separately (visually check that what you're running is right, i.e., gives the same results as reghdfe), then work with that.

    Comment


    • #3
      Originally posted by Ken Yang View Post
      Dear Statalists,

      I am quite new to reghdfe and ivreghdfe. I hope someone can help me with my code.
      I have a panel data with 800 firms of 40 industries in 10 years.

      I want to run 2sls, z directly affects x, but indirectly affects y.

      Code:
      xtset firm year
      
      ivreghdfe y (x = z) $controls, absorb(industry year) first
      outreg2 using myfile.xls, replace stats(coef pval)

      But I could not obtain both the 1st stage and 2nd stage results with outreg2. I have tried to search here, but there is no suggestion to use outreg2 for ivreghdfe.
      Can anyone help me with this, please? I really appreciate your help.

      Regards,
      Ken
      If you use/install estout you can do the following
      Code:
       
       ivreghdfe y (x = z) $controls, absorb(industry year) first savefirst savefprefix(st1) esttab est1 st1*
      However, now that I think about it. You can probably add savefirst and savefprefix(st1) to your command and then find out how it works with outreg. I've never really used outreg.

      Comment


      • #4

        Hello,

        Although it might be too late but it might be useful to others. You could try the following command:

        Code:
        eststo:ivreghdfe y controls (x=iv)  , a(city year )  cluster(city) first savefirst savefp(f) // savefprefix(prefix) option stes a prefix for first stage estimation result
        est restore fx // there must be "f"+"x" 
        outreg2 using iv.doc,cttop(first) replace
        ivreghdfe y controls (x=iv), a(city year ) cluster(city)
        outreg2 using iv.doc,cttop(second)

        Comment

        Working...
        X