Announcement

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

  • exporting mchange results to Word

    Hello,

    Does anyone know if there is a command for exporting results from -mchange- command (after running log reg) to Word? I'm searching for something similar to what is possible with eststo and esttab.

    Thank you!

  • #2
    mchange is part of the spost13 package by Long and Freese, as you are asked to explain in FAQ Advice #12.

    Code:
    findit spost13
    The command does store results in a matrix r(table) in r(). So you can directly export this matrix using esttab (Stata Journal).

    Code:
    mchange
    mat R= r(table)
    esttab mat(R) using myfile.rtf, replace
    .

    Comment


    • #3
      Wonderful! Thank you! And thank you for the notice on how to explain the problem (FAQ12). I have on more follow up question: is it possible to export both matrices: the margins (r(table)) and average predictions (r(basepred) within one table in Word?

      Comment


      • #4
        Yes. Just append the second set of results. You can reverse order, of course.

        Code:
        mchange
        mat R= r(table)
        mat B= r(basepred)
        esttab mat(R) using myfile.rtf, title("Marginal effects") nomtitles replace
        esttab mat(B) using myfile.rtf, title("Average Predictions") nomtitles append
        Last edited by Andrew Musau; 13 Oct 2020, 08:01.

        Comment


        • #5
          Great - it works! Thank you

          Comment


          • #6
            Hi, in case i want to export the results with significance level highlighted by **, how can i do the same for mchange results in the above command.

            Comment


            • #7
              You have a nonstandard matrix, i.e., different in format from a typical e(b) matrix. One of its rows contains the P values, so the best you can do to introduce stars is to set this as a dataset. Here is a way to export to Excel with export excel. I am not too familiar with putdocx, but you can read the documentation.

              Code:
              webuse lbw, clear
              logit low age lwt smoke i.race
              mchange
              mat R= r(table)
              local rows: di `"`:rowname R, quoted'"'
              clear
              gen row=""
              svmat R
              local i 1
              foreach row of local rows{
                  replace row = "`row'" in `i'
                  local ++i
              }
              gen R= string(R1, "%9.3f")+ cond(R2<0.01, "***", cond(inrange(R2, 0.01, 0.05), "** ",cond(inrange(R2, 0.05, 0.1), "*  ", "   " )))
              keep row R
              export excel myfile, replace
              Res.:

              Code:
              . l, sep(0)
              
                   +----------------------------+
                   |            row           R |
                   |----------------------------|
                1. |             +1   -0.004    |
                2. |            +SD   -0.023    |
                3. |       Marginal   -0.004    |
                4. |             +1   -0.002**  |
                5. |            +SD   -0.069**  |
                6. |       Marginal   -0.002**  |
                7. |             +1    0.224*** |
                8. |            +SD    0.106*** |
                9. |       Marginal    0.203*** |
               10. | black vs white    0.243**  |
               11. | other vs white    0.180**  |
               12. | other vs black   -0.063    |
                   +----------------------------+
              Last edited by Andrew Musau; 16 Jan 2022, 10:44.

              Comment

              Working...
              X