使用 esttab 时调整表的大小

Adjusting the size of tables when using esttab

我正在使用 community-contributed 命令将回归结果导出到 tex 文件中 esttab:

esttab using reg.tex, nonumbers mtitles("1" "2" "3" "4" "5" "6" "7" "8" "9")

table 包含九列。

我想将字体大小和列宽调小,以便在 LaTeX 中编译文件时整个 table 可以容纳在页面中。

当我使用 esttab 时,有没有办法直接在 Stata 中执行此操作?

考虑以下使用 Stata 的 auto 玩具数据集的示例:

sysuse auto, clear
eststo clear

eststo: quietly regress price weight
eststo: quietly regress price weight mpg

esttab

--------------------------------------------
                      (1)             (2)   
                    price           price   
--------------------------------------------
weight              2.044***        1.747** 
                   (5.42)          (2.72)   

mpg                                -49.51   
                                  (-0.57)   

_cons              -6.707          1946.1   
                  (-0.01)          (0.54)   
--------------------------------------------
N                      74              74   
--------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

一般来说,列的宽度可以使用 varwidth() and/or modelwidth():

esttab, mlabels(none) varwidth(25)

---------------------------------------------------------
                                   (1)             (2)   
---------------------------------------------------------
weight                           2.044***        1.747** 
                                (5.42)          (2.72)   

mpg                                             -49.51   
                                               (-0.57)   

_cons                           -6.707          1946.1   
                               (-0.01)          (0.54)   
---------------------------------------------------------
N                                   74              74   
---------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

esttab, mlabels(none) modelwidth(25)

----------------------------------------------------------------------
                                   (1)                          (2)   
----------------------------------------------------------------------
weight                           2.044***                     1.747** 
                                (5.42)                       (2.72)   
mpg                                                          -49.51   
                                                            (-0.57)   
_cons                           -6.707                       1946.1   
                               (-0.01)                       (0.54)   
----------------------------------------------------------------------
N                                   74                           74   
----------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

上述两个选项也可以结合使用:

-----------------------------------------------------------------------------------
                                                (1)                          (2)   
-----------------------------------------------------------------------------------
weight                                        2.044***                     1.747** 
                                             (5.42)                       (2.72)   

mpg                                                                       -49.51   
                                                                         (-0.57)   

_cons                                        -6.707                       1946.1   
                                            (-0.01)                       (0.54)   
-----------------------------------------------------------------------------------
N                                                74                           74   
-----------------------------------------------------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

对于 LaTeX 输出,您需要根据需要在 prehead()postfoot() 选项中包含必要的标记。

在此示例中,您可以按如下方式更改 table 的字体大小:

esttab, mlabels(none) tex ///
        prehead(`"\begin{table}"' `"\tiny"' ///
                `"\def\sym#1{\ifmmode^{#1}\else\(^{#1}\)\fi}"' ///
                `"\begin{tabular}{l*{2}{c}}"') ///
        postfoot(`"\end{tabular}"' `"\end{table}"')

同样,您可以通过更改值以下来控制列间距 {5pt}:

esttab, mlabels(none) tex ///
        prehead(`"\setlength{\tabcolsep}{5pt}"' `"\begin{tabular}"')