esttab用逗号和冒号重命名行为

时间:2018-10-16 20:43:04

标签: stata

说我有此数据:

eststo clear
sysuse auto2, clear

我进行回归分析:

reg mpg price turn

我想使用esttab的{​​{1}}功能来重命名变量。但是,当我这样做时:

rename

逗号消失。

当我这样做时:

esttab, rename("price" "(1,2)" "turn" "(3,5)")

我收到一条错误消息。

我曾尝试创建一个本地并在esttab, rename("price" "Var1: (1,2)" "turn" "Var2: (3,5)") 中使用它,但是在那里我也遇到了错误。

rename

但这只是重现了逗号问题。

如何解决这两个问题(尤其是第一个问题)?

local a "(1,2)" display "`a'" esttab, rename("price" "`a'") 社区贡献的命令。

1 个答案:

答案 0 :(得分:2)

似乎,:都用于内部解析,因此如果您想使用rename()选项,就很不走运。

但是,您可以通过执行以下操作来解决这两个问题:

eststo clear
sysuse auto2, clear

label variable price "(1,2)"
label variable turn "(3,5)"

reg mpg price turn
esttab, label

------------------------------------
                              (1)   
                     Mileage (m~)   
------------------------------------
(1,2)                   -0.000534** 
                          (-3.38)   

(3,5)                      -0.835***
                          (-7.89)   

Constant                    57.69***
                          (14.32)   
------------------------------------
Observations                   74   
------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

并且:

label variable price "Var1: (1,2)"
label variable turn "Var2: (3,5)"

reg mpg price turn
esttab, label

------------------------------------
                              (1)   
                     Mileage (m~)   
------------------------------------
Var1: (1,2)             -0.000534** 
                          (-3.38)   

Var2: (3,5)                -0.835***
                          (-7.89)   

Constant                    57.69***
                          (14.32)   
------------------------------------
Observations                   74   
------------------------------------
t statistics in parentheses
* p<0.05, ** p<0.01, *** p<0.001

编辑:

estout的帮助文件确认:

rename(matchlist) changes the names of individual coefficients, where
        matchlist is

            oldname newname [oldname newname ...]

        oldname can be a parameter name (e.g. price) or a full name including
        an equation specification (e.g. mean:price)...

逗号可能用作分隔符。