如何使用 esttab 显示 N 和 R 平方的不同小数位?
How to display different decimal places for N and R-Squared using esttab?
我使用 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, see the online documentation 的 estout
的一部分,用于安装和更多信息。
这是一个使用 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"))
我使用 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, see the online documentation 的 estout
的一部分,用于安装和更多信息。
这是一个使用 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"))