Announcement

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

  • Combining T-Stats and SEs

    Say I want to make a latex table of T-stats and their associated SEs, where say the column title is what the "by" is and the row is the coefficient for the variable and SE.
    Code:
    sysuse auto, clear
    
    cls
    
    g twoton = cond(weight>4000,1,0)
    
    estpost ttest price mpg, by(foreign)
    
    estpost ttest price mpg, by(twoton)
    I know I could simply extract the e(b) vector and combine them into one matrix/table, but I'm unsure of how I'd incorporate the SEs into it.

    Note that I'm a dinosaur, I'm still using 17, so I wonder if there's some nice way in collect to do this

  • #2
    Here is what I came up with based on your example and description.
    Code:
    sysuse auto
    
    g twoton = cond(weight>4000,1,0)
    
    estpost ttest price mpg, by(foreign)
    collect get e(t) e(se), tags(var[foreign])
    
    estpost ttest price mpg, by(twoton)
    collect get e(t) e(se), tags(var[twoton])
    
    collect style column, dups(center)
    collect style cell result[t se], nformat(%12.3f)
    
    collect layout (colname#result) (var)
    collect export ttable.tex, replace
    Here is the resulting table.
    Code:
    ----------------------------------
                  | Car origin  twoton
    --------------+-------------------
    Price         |
      t           |     -0.414  -4.929
      se          |    754.449 913.378
    Mileage (mpg) |
      t           |     -3.631   3.475
      se          |      1.362   1.917
    ----------------------------------

    Comment


    • #3
      Okay thank you!

      Comment


      • #4
        Using estout from SSC:

        Code:
        sysuse auto, clear
        gen twoton = cond(weight>4000,1,0)
        estpost ttest price mpg, by(foreign)
        est sto foreign
        estpost ttest price mpg, by(twoton)
        est sto twoton
        esttab foreign twoton, cells(t(fmt(a3)) se(par fmt(a3))) label ///
        mlab(Foreign Twoton, lhs(Variables)) nonumb collab(none) ///
        note(t-statistics with standard errors in parentheses) tex
        Res.:

        Code:
        . esttab foreign twoton, cells(t(fmt(a3)) se(par fmt(a3))) label ///
        > mlab(Foreign Twoton, lhs(Variables)) nonumb collab(none) ///
        > note(t-statistics with standard errors in parentheses)
        
        ----------------------------------------------
        Variables                 Foreign       Twoton
        ----------------------------------------------
        Price                      -0.414       -4.929
                                  (754.4)      (913.4)
        Mileage (mpg)              -3.631        3.475
                                  (1.362)      (1.917)
        ----------------------------------------------
        Observations                   74           74
        ----------------------------------------------
        t-statistics with standard errors in parentheses

        Comment

        Working...
        X