Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Add Cohen's d effect size to esttab t-test table

    Hi Everyone,

    I am trying to create a (Latex) table in which I compare the means of two different subsamples. I want to show the two sample means, the difference (ideally also stars on this indicating significance from a t-test), as well as the Cohen's d effect size. The first three columns I can create quite easily following general estout/esttab syntax. However I don't know how to add another column that includes the Cohen's d statistics. Is there a manual way to add this? Any help would be highly appreciated.
    Code:
    *code generating first three columns
    eststo matching_bal: estpost ttest var1 var2 var3 if sample==1, by(realized)
    esttab matching_bal using 200612_sum_table_matching.tex, cells("mu_1(fmt(a2) label(Mean)) mu_2(fmt(a2) label(Mean)) b(par fmt(a2) label(Diff))") tex replace label nonumber
    *calculating cohens d statistics
    esize twosample var1 if sample==1, by(realized) cohensd 
    esize twosample var2 if sample==1, by(realized) cohensd 
    esize twosample var3 if sample==1, by(realized) cohensd

    Thanks so much. Here's some example data, if it's helpful:


    Code:
    * Example generated by -dataex-. To install: ssc install dataex
    clear
    input float var1 int var2 byte var3 float realized
     7.784057 1903 1 0
      8.77137 1975 1 1
     5.602119 1996 1 1
     5.484797 1990 1 0
     8.464214 1989 1 1
     7.809947 1904 1 0
     7.405496 1992 1 1
     7.766417 1984 1 0
    1.3862944 2001 0 0
    1.3862944 1985 0 1
     7.794823 1983 1 1
     6.728629 1962 1 0
     6.699501 1985 1 0
     6.701961 1987 1 1
     6.059123 1982 1 0
     6.419995 1993 1 1
    4.1271343 1983 0 1
    4.1431346 1999 0 0
     6.261492 1978 1 1
     6.826545 1984 1 0
     8.172165 1991 1 0
     8.557759 1987 1 1
     7.784057 1903 1 0
      8.77137 1975 1 1
     6.736967 1992 1 0
      7.30317 1987 1 1
     9.484101 1992 0 1
     9.096724 1977 0 0
     6.996682 1983 1 0
     6.820016 1996 1 1
     8.464214 1989 1 0
     7.809947 1904 1 1
     7.496098 1988 1 0
     7.573531 1967 1 1
     9.096724 1977 1 0
     9.484101 1992 1 1
     8.528331 1987 1 0
     8.561593 1987 1 1
      9.01018 1977 1 0
     8.676416 1964 1 1
     7.239215 1993 1 1
      6.84375 1976 1 0
     7.311218 1986 1 1
     7.285507 1987 1 0
     7.987185 1964 1 1
       8.6174 1972 1 0
     8.111328 1989 1 1
     8.438582 1987 1 0
     8.676416 1964 1 0
      9.01018 1977 1 1
     8.568076 1977 1 1
      9.01018 1977 1 0
     9.105758 1992 1 1
     9.027259 1974 1 0
      9.01018 1977 1 1
     8.676416 1964 1 0
     6.628041 1989 0 0
     5.918894 1965 0 1
     5.347107 1977 0 0
     5.676754 1993 0 1
     9.027259 1974 1 0
     9.105758 1992 1 1
     7.952263 1991 1 0
     7.573531 1967 1 1
     9.484101 1992 1 1
     9.096724 1977 1 0
     6.475433 1996 1 1
     6.476973 1996 1 0
     4.624973 1987 1 1
     4.406719 1994 1 0
     7.794823 1983 1 1
     6.728629 1962 1 0
      7.38709 1994 1 0
     7.203405 1993 1 1
     8.172165 1991 0 0
     8.557759 1987 0 1
     8.541105 1977 1 1
     8.574518 1980 1 0
     5.308268 1993 1 1
     4.983607 1976 1 0
      9.01018 1977 1 0
     8.568076 1977 1 1
     6.161207 1986 1 1
     5.932245 1995 1 0
     5.726848 1972 0 0
     5.332719 1987 1 1
     9.096724 1977 1 0
     9.484101 1992 1 1
     9.813508 1945 1 1
     8.676416 1964 1 0
    4.1271343 1983 1 1
    4.1431346 1999 1 0
      7.30586 1996 1 1
     7.190676 1991 1 0
      8.33663 1987 1 1
     7.900637 1974 1 0
     9.096724 1977 1 0
     9.484101 1992 1 1
     7.118016 1987 0 0
     6.892642 1994 0 1
    end
Working...
X