Announcement

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

  • xtivreg2 export first and second stage results

    As the description of xtivreg2 says, it is the wrapper of ivreg2. But the "savefirst“ option of ivreg2 could actually store the first stage result, so it's easy for ivreg2 to export it. Although user could add "savefirst" option in xtivreg2 command, and it runs without an error, it still no result is stored like "ivreg2 xxx, savefirst" does.
    If I have to use xtivreg2 for fixed effect estimation, is there a way to export first and second stage results at the same time? Thanks.

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

    Comment


    • #3
      Thank you very much, Andrew. It really helps.

      Comment


      • #4
        Hi, Andrew. If I may ask another relevant question. When outputting more than one time results, lets say we have two regressions to run and to output, my expection is to output the two results in the same table, which means if running the code below, i was hoping to get a n×4 table in myfile.rtf. But now I just get two n×2 tables in myfile.rtf, since each regression will be outputed as a n×2 table.


        Code:
        *the first regression
        eststo: xi: xtivreg2 A (B = C) i.year, fe first savefirst savefprefix(st1)
        esttab est1 st1* using myfile.rtf, replace  
        eststo clear
        estimates clear  
        *the second regression
        eststo: xi: xtivreg2 A (D = E) i.year, fe first savefirst savefprefix(st1)
        esttab est1 st1* using myfile.rtf, append
        I am wondering if there is some solution to get a n×4 table, cause I got many estimates to output. Thank you again.
        Last edited by Johnny Cash; 21 May 2020, 10:21.

        Comment


        • #5
          You want to output all the results simultaneously, so assign different prefixes to the first-stage estimates.

          Code:
          eststo clear
          *the first regression
          eststo: xi: xtivreg2 A (B = C) i.year, fe first savefirst savefprefix(st1)
          *the second regression
          eststo: xi: xtivreg2 A (D = E) i.year, fe first savefirst savefprefix(st2)
          esttab est1 st1* est2 st2* using myfile.rtf, replace

          Comment


          • #6
            Originally posted by Andrew Musau View Post
            You want to output all the results simultaneously, so assign different prefixes to the first-stage estimates.

            Code:
            eststo clear
            *the first regression
            eststo: xi: xtivreg2 A (B = C) i.year, fe first savefirst savefprefix(st1)
            *the second regression
            eststo: xi: xtivreg2 A (D = E) i.year, fe first savefirst savefprefix(st2)
            esttab est1 st1* est2 st2* using myfile.rtf, replace
            Thank u Andrew, it really helps. It's so kind of u to answer questions with patience.

            Comment


            • #7
              Originally posted by Andrew Musau View Post
              You want to output all the results simultaneously, so assign different prefixes to the first-stage estimates.

              Code:
              eststo clear
              *the first regression
              eststo: xi: xtivreg2 A (B = C) i.year, fe first savefirst savefprefix(st1)
              *the second regression
              eststo: xi: xtivreg2 A (D = E) i.year, fe first savefirst savefprefix(st2)
              esttab est1 st1* est2 st2* using myfile.rtf, replace
              Hi Andrew, do you know how to clear the results stored in "savefprefix"? I find that I cannot overwrite the early results when I use st1, st2 next time.

              Comment


              • #8
                Code:
                estimates drop st1
                before the command should clear the previously stored estimates "st1".

                Comment

                Working...
                X