Announcement

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

  • Exporting first stage results after -xtivreg-

    Dear All,

    I am trying to extract the first stage results to an excel file.
    I am doing a REIV as shown below.

    Code:
    xi: xtivreg $Y $X8 (crtrvtmp= $IV) if female==0, re vce(bootstrap, reps(400) seed(1)) first small
    I tried several suggested commands for -ivreg- but they did not work after -xtivreg-

    Please advise me.

    Best regards,
    Maye

  • #2
    Hi Maye,

    One simple solution is to just estimate your first stage separately and export the results using a program like estout, as in
    Code:
    xi: xtreg crtrvtmp $IV $X8, re vce(bootstrap, reps(400) seed(1)) 
    test $IV
    Of course this may not be satisfactory because you will have to re-estimate your bootstrap standard errors. Also I am not familiar enough with the econometrics of random effects IV to say for sure that your first stage standard errors will be identical (although I guess you can check that.)

    Also the command xtivreg2 lets you save the first stage estimation results, with the option savefirst. That command does not support random effects, however, only fixed effects or first differences.

    Comment


    • #3
      Just to remark, for those with recent versions of Stata, the prefix xi: is not necessary.
      Best regards,

      Marcos

      Comment


      • #4
        Thanks Dan for the solution. I will do this suggestion.
        Thanks Marcos for the remark.

        Comment


        • #5
          Originally posted by Dan Sacks View Post
          Hi Maye,

          One simple solution is to just estimate your first stage separately and export the results using a program like estout, as in
          Code:
          xi: xtreg crtrvtmp $IV $X8, re vce(bootstrap, reps(400) seed(1))
          test $IV
          A follow up question on this suggestion...
          I have several models with several dependent variables and basically the first stage results can vary. how to tackle this issue depending on ur suggested method for exporting the results?

          Best,
          Maye

          Comment


          • #6
            Dear Dan,

            I found the answer to my question and thought of sharing it with you:
            It is shown in the below link:
            HTML Code:
            http://statalist.1588530.n2.nabble.com/st-outreg2-with-xtivreg-td2623466.html
            And here is the code:
            Code:
            ** for random effects 
            sysuse auto, clear 
            *2sls  
            xtivreg headroom (rep78=gear turn) trunk length, i(foreign) first 
            *First stage but The trick is to use e(sample) to make sure 
            *you are using the same sample. 
            *Just remember that the first-stage must include all right-hand side variables, 
            *including the instruments. 
            reg rep78 trunk length gear turn if e(sample)==1 
            outreg2 using myfile, replace 
            * second stage
            xtivreg (rep78=gear turn) headroom trunk length, i(foreign) 
            *The below command adds the results of the second stage next to the results retrieved from the previous first stage.
            outreg2 using myfile, sortvar(rep78) see
            Best regards,
            Maye

            Comment


            • #7
              Thank you for sharing it, Maye.
              Best regards,

              Marcos

              Comment


              • #8
                Hi

                #7: To my knowledge, we can't copy and paste results to excel because standard errors will become negative (because they are in parentheses).

                Here is my suggestion:
                Code:
                eststo clear
                eststo: qui xtivreg headroom (rep78=gear turn) trunk length, i(foreign) first 
                eststo: qui reg rep78 trunk length gear turn if e(sample)==1 
                
                // Export to excel
                esttab * using result.csv, cells(b(star fmt(3) label(Coef.)) t(par fmt(3))) ///
                starlevels(* 0.10 ** 0.05 *** 0.010) stats(N r2, labels ("No. of Obs." "R-square") fmt(0 3)) replace
                --------------------
                (Stata 15.1 MP)

                Comment

                Working...
                X