如何解决如何使用esttab为N和R平方显示不同的小数位?
我使用esttab
生成回归表。请参见下面的示例代码。
eststo clear
eststo: reghdfe y x1,absorb(year state) cluster(year state)
estadd local FE "Yes"
estadd local Controls "No"
eststo: reghdfe y x1 x2 x3,absorb(year state) cluster(year state)
estadd local FE "Yes"
estadd local Controls "Yes"
esttab,star(* 0.10 ** 0.05 *** 0.01) b(3) t(2) r2 replace label drop(_cons) stats(FE Conrols N r2,fmt(%9.0fc) labels("Fixed Effects" "Controls" "Obserations" "R-Squared"))
因为我的数据集很大,所以我使用fmt(%9.0fc)
将逗号添加到我的观测值中。但是,此选项将我的R平方四舍五入为0。如何为观察值使用整数(带逗号),对R平方使用小数点后三位?
还可以显示调整后的R平方吗?用户手册建议stats
禁用ar2
,但我很难找到解决方法。
解决方法
esttab
是Ben Jann的estout
的一部分,有关安装和更多信息,请参见online documentation。
这是使用esttab
的默认格式的最小工作示例。
eststo clear
sysuse auto
eststo: quietly regress price weight mpg
eststo: quietly regress price weight mpg foreign
esttab,star(* 0.10 ** 0.05 *** 0.01) ///
b(3) t(2) ar2
请注意,ar2
调用了调整后的R ^ 2。但是,如果您要使用stats()
选项来设置obs的格式,那么语法更改将是:
esttab,star(* 0.10 ** 0.05 *** 0.01) ///
b(3) t(2) ///
stats(N r2_a)
要应用格式,请为每个统计信息添加一个字词,如果您提供的字数少于统计信息,则esttab
将最后一个字词应用于其余统计信息。这就是为什么您的R ^ 2四舍五入为零的原因。请尝试以下操作:
esttab,star(* 0.10 ** 0.05 *** 0.01) ///
b(3) t(2) ///
stats(N r2_a,fmt(%9.0fc %9.2fc)
因此,我将按如下所示编辑您的esttab
行:
esttab,star(* 0.10 ** 0.05 *** 0.01) ///
b(3) t(2) /// no 'ar2' here
label /// note you only need 'replace' if you are generating a file
nocons /// 'reghdfe' has an option to 'drop(_cons)'
stats(FE Controls N r2_a,/// 'Controls' not 'Conrols'
fmt(%9.0fc %9.0fc %9.0fc %9.2fc) /// it seems you need place holders for the string stats
labels("Fixed Effects" "Controls" "Obserations" "R-Squared"))
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。