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

              Working...
              X