【问题标题】:Adjusting the size of tables when using esttab使用 esttab 时调整表的大小
【发布时间】:2015-10-25 11:26:03
【问题描述】:

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

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

该表包含九列。

当我在LaTeX 中编译文件时,我想缩小字体大小和列宽,以便整个表格可以适合页面。

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

【问题讨论】:

  • 您可以将可选的(fmt) 格式化命令添加到您请求的估算值中。例如,选项b(1) 仅显示小数点后一位,而不是默认的三位。虽然这会使您的表格不那么宽,但它是否仍然提供信息取决于您的数据。 compress 选项减少了水平间距,但不会影响您的 Latex 表格。最后,您可以将整个表格放在 Latex 中的横向页面中,这样可以为您提供更多的水平空间。
  • 我以前一直有这个问题。我开始使用的开箱即用解决方案是导出到 .csv 文件,然后使用 Excel 或 OpenOfficeCalc 进行编辑。使用“Excel2LaTeX”或“Calc2LaTeX”转换为tex

标签: latex stata


【解决方案1】:

考虑以下使用 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() 和/或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() 选项中酌情包含必要的标记。

在本例中,您可以按如下方式更改表格的字体大小:

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}"')

【讨论】:

    猜你喜欢
    • 2016-06-18
    • 2012-08-21
    • 1970-01-01
    • 1970-01-01
    • 2020-02-21
    • 2011-11-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多