Announcement

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

  • Multiline mtitles in -esttab-

    Dear Statalisters,
    Im using -esttab- to create latex tables from regressions .

    esttab model1 model2 model3 using table.tex, mlabels("Fixed effect" "Reduced form fixed effect" "Fixed effect IV")
    Often, the model title becomes to long, and I would have liked to have two lines in latex with the model title. E.g. putting "Reduced form" on the line above "fixed effect" for the second model above.

    Is there a way to do this, apart from manually fixing it in the tex file afterwards?

    Thanks a lot for any help!

    Best
    Andreas


  • #2
    There are a few ways, all of which involve using LaTeX code, but my favorite is \shortstack{}:

    Code:
    mtitles("Fixed effect" "\shortstack{Reduced form\\fixed effect}" "Fixed effect IV")
    Note about backslashes: both Stata and TeX use the backslash as an escape character. Things can get confusing if you want to, say, store your model titles as Stata macros, because the macro will be evaluated when Stata prints it. -macval()- is your friend if you want to put TeX code in Stata macros.

    Terminology note: -mlabels- and -mtitles- are not exactly the same thing. -mlabels- is really an -estout- option, but is permitted for -esttab- like all -estout- options. Since you are using -esttab-, -esttab, mlabels()- is best avoided. Stick with -esttab, mtitles()- unless you have a specific reason.
    Last edited by Nils Enevoldsen; 17 May 2015, 12:51.

    Comment


    • #3
      Thanks! this was helpful.

      Comment


      • #4
        Dear Stata friends, this is my first post, I hope I am following the rules.
        I'd like to have multiline titles in an esttab table just as in the example, but without using latex, i.e., directly in the Stata results window.
        Is that possible? I've been looking for that but couldn't find any help for that.
        Thanks in advance. Best regards,
        Andrés

        Comment


        • #5
          I don't know if that's possible. You can look up SMCL markup with help smcl for ideas.

          I tried the following, but it didn't work.

          Code:
          . sysuse auto, clear
          . reg price weight
          . esttab ., mtitles("Foo{break}Bar")
          
          ----------------------------
                                (1)   
                       Foo
          ~r   
          ----------------------------
          weight              2.044***
                             (5.42)   
          
          _cons              -6.707   
                            (-0.01)   
          ----------------------------
          N                      74   
          ----------------------------
          t statistics in parentheses
          * p<0.05, ** p<0.01, *** p<0.001

          Comment


          • #6
            You can get two lines with a combination of mgroups() and mtitles()

            Code:
            sysuse auto, clear 
            reg price weight
            esttab .,mgroups("Two ") mtitles("is OK")  nonumbers
            Result:

            Code:
            ----------------------------
                                 Two    
                                is OK  
            ----------------------------
            weight              2.044***
                               (5.42)  
            
            _cons              -6.707  
                              (-0.01)  
            ----------------------------
            N                      74  
            ----------------------------
            t statistics in parentheses
            * p<0.05, ** p<0.01, *** p<0.001

            Comment


            • #7
              Thank you Nils and Andrew, I think that the mgroups() and mtitles() combination solves the problem! Best regards and nice analyses,
              Andrés

              Comment


              • #8
                I am using these to create a table, but I want to rename my columns to column1- robust st.errors, column 2: cluster robust, Instead of FLPR
                (1) (2)
                FLPR FLPR
                FDIIFLOWS_LOG -0.2957*** -0.2957***
                (0.1041) (0.0822)
                GDPGrowth -0.0019 -0.0019
                (0.0240) (0.0247)
                NaturalresourceRent -0.0343 -0.0343
                (0.0327) (0.0259)
                Generalgovernmentexpenditure 0.0422 0.0422
                (0.0587) (0.0376)
                Schoolsecondaryfemale -0.0496 -0.0496**
                (0.0390) (0.0209)
                UrbanPopulationControl 0.0762 0.0762
                (0.1345) (0.0450)
                polity2 -0.1295 -0.1295**
                (0.0787) (0.0606)
                Exports 0.0468 0.0468***
                (0.0356) (0.0122)
                Fertilityrate 0.4640 0.4640
                (0.8038) (0.3152)
                _cons 52.6528*** 52.6528***
                (7.4203) (2.7614)
                N 803 803
                R2 0.154
                The commands I used:

                xtreg FLPR FDIIFLOWS_LOG GDPGrowth NaturalresourceRent Generalgovernmentexpenditure Schoolsecondaryfemale UrbanPopulationControl polity2 Exports Fertilityrate, fe cluster( countrycode)
                eststo
                xtreg FLPR FDIIFLOWS_LOG GDPGrowth NaturalresourceRent Generalgovernmentexpenditure Schoolsecondaryfemale UrbanPopulationControl polity2 Exports Fertilityrate, fe vce(robust)
                eststo
                xtscc FLPR FDIIFLOWS_LOG GDPGrowth NaturalresourceRent Generalgovernmentexpenditure Schoolsecondaryfemale UrbanPopulationControl polity2 Exports Fertilityrate, fe
                eststo
                esttab using myfile21.rtf , star(* .10 ** .05 *** .01) b(4) se r2 nogaps

                Comment


                • #9
                  Code:
                  esttab using myfile21.rtf , star(* .10 ** .05 *** .01) b(4) se r2 nogaps mtitles("Robust SE" "Cluster Robust")

                  Comment


                  • #10
                    Thank you sooooo much :D

                    Comment


                    • #11
                      Is this still supposed to work (in 2023) in #2?
                      HTML Code:
                        mtitles("Fixed effect" "\shortstack{Reduced form\\fixed effect}" "Fixed effect IV")
                      Stata seems to print the whole thing, including \shortstack.
                      Last edited by Castor Comploj; 10 Jun 2023, 07:28.

                      Comment


                      • #12
                        Yes, it still works. Are you exporting a LaTeX table, or using a different export format?

                        Comment


                        • #13
                          Understood.
                          I wrote above using html. I see now that this thread is using LaTeX.

                          Comment

                          Working...
                          X