Announcement

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

  • Flipping tables using eststo.

    Hi, I have a question concerning the construction of tables using eststo and esttab and posting them in LaTex. My problem is that I have 6 models that I am running and they don't fit horizontally on a piece of paper, therefore, am trying to flip the table vertically. Does anybody know how I can solve it??

    My intuition is that I should do something in the esttab command.

    This is my code so fare.
    eststo clear

    eststo Fixed: xtreg y x1-x5, fe vce(cluster region)
    estadd local fixed "Yes" , replace
    estadd local controls "Yes" , replace

    eststo CRE: xtreg y x1-x5 , re vce (cluster region)
    estadd local fixed "No" , replace
    estadd local controls "No" , replace


    eststo CRE_Fiexed_Effects: xtreg y x1-x5, re vce (cluster kommun_num)
    estadd local fixed "Yes" , replace
    estadd local controls "Yes" , replace
    .
    .
    Three models more.

    esttab using tutorial_auto_reg_1.tex, label replace booktabs title(Regression table\label{tab1}) p nodepvars s(fixed controls N, label("Fixed Effects" "Controls"))

  • #2
    esttab is from the Stata Journal, as you are asked to explain (FAQ Advice # 12). Unless I am mistaken, you have to copy the tex tables generated by esttab and paste to your tex editor, unlike MS Word or MS Excel documents where the file is created directly. Therefore, just create the tables separately and append them when copying and pasting. Ensure an even distribution of models across tables.

    Code:
    sysuse auto, clear
    eststo m1: qui reg mpg price weight
    eststo m2: qui reg mpg price weight length
    eststo m3: qui reg mpg price weight length displacement
    eststo m4: qui reg mpg price weight length displacement trunk
    *COMBINE 1 & 2 AND 3 &4
    esttab m1 m2,stats(j r2 N j, labels("\midrule" "R-squared" "Obs" "\midrule")) plain not tex nomtitle collabels(none) numbers title("Auto Regressions")
    esttab m3 m4,stats(j r2 N j, labels("\midrule" "R-squared" "Obs" "\midrule")) plain not tex nomtitle collabels(none) numbers title("Auto Regressions")
    The result is:

    Code:
    .
    . esttab m1 m2,stats(j r2 N j, labels("\midrule" "R-squared" "Obs" "\midrule")) plain not tex nomti
    > tle collabels(none) numbers title("Auto Regressions")
    
    \begin{table}[htbp]\centering
    \caption{Auto Regressions}
    \begin{tabular}{l*{2}{c}}
                &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}\\
    price       &   -.0000935&   -.0001733\\
    weight      &   -.0058175&   -.0030371\\
    length      &            &   -.0965706\\
    \_cons      &    39.43966&    49.68492\\
    \midrule    &            &            \\
    R-squared   &    .6531447&    .6664835\\
    Obs         &          74&          74\\
    \midrule    &            &            \\
    \end{tabular}
    \end{table}
    
    .
    . esttab m3 m4,stats(j r2 N j, labels("\midrule" "R-squared" "Obs" "\midrule")) plain not tex nomti
    > tle collabels(none) numbers title("Auto Regressions")
    
    \begin{table}[htbp]\centering
    \caption{Auto Regressions}
    \begin{tabular}{l*{2}{c}}
               &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}\\
    price       &   -.0001742&   -.0001729\\
    weight      &   -.0035428&   -.0035878\\
    length      &   -.0947189&   -.0894247\\
    displacement&    .0043254&    .0044475\\
    trunk       &            &   -.0308326\\
    \_cons      &    50.01615&    49.54909\\
    \midrule    &            &            \\
    R-squared   &    .6674163&    .6676594\\
    Obs         &          74&          74\\
    \midrule    &            &            \\
    \end{tabular}
    \end{table}
    Just copy the blue part and append to the first table. I removed the notes from the tables, but you can include these in the first table. Thereafter, manually change the column numbers in the appended table(s), highlighted in red above. The final table should look like

    Code:
    \begin{table}[htbp]\centering
    \caption{Auto Regressions}
    \begin{tabular}{l*{2}{c}}
                &\multicolumn{1}{c}{(1)}&\multicolumn{1}{c}{(2)}\\
    price       &   -.0000935&   -.0001733\\
    weight      &   -.0058175&   -.0030371\\
    length      &            &   -.0965706\\
    \_cons      &    39.43966&    49.68492\\
    \midrule    &            &            \\
    R-squared   &    .6531447&    .6664835\\
    Obs         &          74&          74\\
    \midrule    &            &            \\
    &\multicolumn{1}{c}{(3)}&\multicolumn{1}{c}{(4)}\\
    price       &   -.0001742&   -.0001729\\
    weight      &   -.0035428&   -.0035878\\
    length      &   -.0947189&   -.0894247\\
    displacement&    .0043254&    .0044475\\
    trunk       &            &   -.0308326\\
    \_cons      &    50.01615&    49.54909\\
    \midrule    &            &            \\
    R-squared   &    .6674163&    .6676594\\
    Obs         &          74&          74\\
    \midrule    &            &            \\
    \end{tabular}
    \end{table}
    And the table resulting table is
    Click image for larger version

Name:	AR.png
Views:	1
Size:	55.1 KB
ID:	1586343

    Last edited by Andrew Musau; 17 Dec 2020, 04:10.

    Comment

    Working...
    X