Как объединить различные наборы estpost в esttab - PullRequest
0 голосов
/ 26 апреля 2019

Рассмотрим следующий фрагмент кода:

*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})

При этом используется команда *1005*, предоставленная сообществом esttab, для создания таблицы со средними и стандартными отклонениями для summstats, treated и non_treated.

Однако в последнем столбце я получаю только значимые звезды.

Как вместо этого можно отобразить фактическое значение p?

1 Ответ

1 голос
/ 26 апреля 2019

Следующее производит желаемый вывод:

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
------------------------------------------------------------------------
...