如何将固定效果模型标签添加到estout表中? [英] How can I add a fixed effect model label to an estout table?
本文介绍了如何将固定效果模型标签添加到estout表中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面您可以找到我的代码:
#delimit;
local fixed_effect "Yes";
estout pre_post using output.xls, cells(b(star fmt(4) keep(post
`ctrlVars')) t(par fmt(2) keep(post `ctrlVars')))
legend starlevels( * 0.10 ** 0.05 *** 0.010) stats(`fixed_effect' r2 N
labels("Industry fixed effects" "Adjusted R-squared")) varlabels(_cons
Constant) append;
这会产生以下错误消息:
( invalid name
"Industry fixed effects invalid name
"Adjusted R-squared invalid name
) invalid name
r(7);
出什么问题了?
编辑:
对不起,我说得不够清楚。这是我想要的:
----------------------------
(1)
Industry FEs
b/t
----------------------------
mpg -174.3133*
(-1.99)
headroom -520.2934
(-1.23)
length 31.3659
(1.30)
Constant 5540.3487
(0.94)
----------------------------
Industry FE Yes
Adjusted R~d 0.2454
N 74
----------------------------
* p<0.10, ** p<0.05, *** p<0.010
推荐答案
我可以使用Stata的玩具数据集auto
重现您的问题,如下所示:
sysuse auto, clear
regress price mpg headroom length
#delimit;
esttab ., cells(b(star fmt(4)) t(par fmt(2)))
legend starlevels( * 0.10 ** 0.05 *** 0.010) stats(r2 N
label("Industry fixed effects" "Adjusted R-squared")) varlabels(_cons
Constant);
( invalid name
"Industry fixed effects invalid name
"Adjusted R-squared invalid name
) invalid name
r(7);
发生此错误是因为您错误地使用了社区贡献的命令estout
的选项:labels()
是stats()
的子选项,因此必须使用逗号分隔。此外,您还需要使用独立选项mlabels()
来指定自定义型号名称:
esttab ., cells(b(star fmt(4)) t(par fmt(2))) legend ///
starlevels(* 0.10 ** 0.05 *** 0.010) stats(r2 N, labels("Adjusted R-squared")) ///
mlabels("Industry FEs") varlabels(_cons Constant)
----------------------------
(1)
Industry FEs
b/t
----------------------------
mpg -174.3133*
(-1.99)
headroom -520.2934
(-1.23)
length 31.3659
(1.30)
Constant 5540.3487
(0.94)
----------------------------
Adjusted R~d 0.2454
N 74.0000
----------------------------
* p<0.10, ** p<0.05, *** p<0.010
请注意,delimit
似乎也会导致一些问题。
编辑:
为此需要使用estadd
:
sysuse auto, clear
regress price mpg headroom length
estadd local fe Yes
esttab ., cells(b(star fmt(4)) t(par fmt(2))) legend ///
starlevels(* 0.10 ** 0.05 *** 0.010) stats(fe r2 N, ///
labels("Industry FE" "Adjusted R-squared")) ///
mlabels("Industry FEs") varlabels(_cons Constant)
----------------------------
(1)
Industry FEs
b/t
----------------------------
mpg -174.3133*
(-1.99)
headroom -520.2934
(-1.23)
length 31.3659
(1.30)
Constant 5540.3487
(0.94)
----------------------------
Industry FE Yes
Adjusted R~d 0.2454
N 74.0000
----------------------------
* p<0.10, ** p<0.05, *** p<0.010
这篇关于如何将固定效果模型标签添加到estout表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文