如何在esttab中组合各种estpost集

时间:2019-04-26 18:38:00

标签: stata

请考虑以下代码段:

*Here I'm storing t-test as ttests
eststo ttests: estpost ttest Gender Black White, by(treated)

*Here this is the summary of all variable + 
eststo summstats: estpost summarize Gender Black White
eststo treated: estpost summarize Gender Black White if treated==1
eststo non_treated: estpost summarize  Gender Black White if treated==0

*table 1: Descriptive data
esttab summstats treated non_treated ttests using "${pathtable}\table_1.tex", label ///
replace main(mean %6.2f) aux(sd) mtitle("Total Sample" "Participants" "Non-Participants" ///
"p-value") title(Descriptive Table\label{tab1})

这使用 community-contributed 命令esttab来生成一个表格,其中包含summstatstreatednon_treated的均值和标准差。

但是,在最后一列中,我仅获得有意义的星星。

如何显示实际的p值?

1 个答案:

答案 0 :(得分:1)

以下将产生所需的输出:

sysuse auto, clear
eststo clear

eststo ttests: estpost ttest price mpg trunk, by(foreign)

eststo summstats: estpost summarize price mpg trunk
eststo treated: estpost summarize price mpg trunk if foreign==1
eststo non_treated: estpost summarize price mpg trunk if foreign==0

esttab summstats             ///
       treated               ///
       non_treated           ///
       ttests,               ///
       cell(p(fmt(%6.3f)) &  ///
       mean(fmt(%6.2f))      ///
       sd(fmt(%6.3f) par))   ///
       label replace         ///
       mtitle("Total"        ///
              "Foreign"      ///
              "Domestic"     ///
              "p-value")     ///
       title(Descriptive     ///
             Table)          ///
       collabels(none)

 Descriptive Table
------------------------------------------------------------------------
                              (1)          (2)          (3)          (4)
                            Total      Foreign     Domestic      p-value
------------------------------------------------------------------------
Price                     6165.26      6384.68      6072.42       0.680 
                       (2949.496)   (2621.915)   (3097.104)             
Mileage (mpg)               21.30        24.77        19.83       0.001 
                          (5.786)      (6.611)      (4.743)             
Trunk space (.. ft.)        13.76        11.41        14.75       0.002 
                          (4.277)      (3.217)      (4.306)             
------------------------------------------------------------------------
Observations                   74           22           52           74
------------------------------------------------------------------------