Announcement

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

  • Constructing individual output table based on stored test estimates (not regression estimates)

    Dear all,
    is there any elegant way to plot a table filled with estimates from ttest and sum commands?

    Currently, I am doing it manually, however I guess a more professional solution is achievable. First, the output table could be presented without the comands in between and second, ideally, the table would be exportable to tex and xls, e.g. with the logout command.

    I am looking forward receiving helpful suggestions on how to improve my code.

    Best
    Christian

    Code:
    *Store t-values and sample size
    qui ttest portfolio_size == 0 if sample_small == 1
    local 1_n = r(N_1)
    local 1_t = r(t)
    qui ttest portfolio_size == 0 if sample_small == 1 & portfolio_size > 2
    local 2_n = r(N_1)
    local 2_t = r(t)
    qui ttest portfolio_size == 0 if sample_small == 1 & portfolio_size > 5
    local 3_n = r(N_1)
    local 3_t = r(t)
    qui ttest portfolio_size == 0 if sample_small == 1 & portfolio_size > 10
    local 4_n = r(N_1)
    local 4_t = r(t)
    
    *Store PP and SD
    sum prox_pref if sample_small == 1
    local 1_pp = r(mean)
    local 1_sd = r(sd)
    sum prox_pref if sample_small == 1 & portfolio_size > 2
    local 2_pp = r(mean)
    local 2_sd = r(sd)
    sum prox_pref if sample_small == 1 & portfolio_size > 5
    local 3_pp = r(mean)
    local 3_sd = r(sd)
    sum prox_pref if sample_small == 1 & portfolio_size > 10
    local 4_pp = r(mean)
    local 4_sd = r(sd)
    
    *Store TAD
    sum distance_actual if sample_small == 1
    local 1_tad = r(mean)
    sum distance_actual if sample_small == 1 & portfolio_size > 2
    local 2_tad = r(mean)
    sum distance_actual if sample_small == 1 & portfolio_size > 5
    local 3_tad = r(mean)
    sum distance_actual if sample_small == 1 & portfolio_size > 10
    local 4_tad = r(mean)
    
    *Display
    noisily display _column(1) "Portf.-size" _column(20) "n" _column(30) "avg. PP" _column(40) "s.d." _column(50) "t-value" _column(65) "avg. TAD" _column(80) "avg. PP / avg. TAD"
    noisily display _column(1) ">= 1+1" _column(20)"`1_n'" _column(30) string(round(`1_pp',0.1)) _column(40) string(round(`1_sd',0.1)) _column(50) string(round(`1_t',0.01)) _column(65) string(round(`1_tad',0.1)) _column(80) string(round((`1_pp'/`1_tad')*100,0.1))
    noisily display _column(1) ">= 2+1" _column(20)"`2_n'" _column(30) string(round(`2_pp',0.1)) _column(40) string(round(`2_sd',0.1)) _column(50) string(round(`2_t',0.01)) _column(65) string(round(`2_tad',0.1)) _column(80) string(round((`2_pp'/`2_tad')*100,0.1))
    noisily display _column(1) ">= 5+1" _column(20)"`3_n'" _column(30) string(round(`3_pp',0.1)) _column(40) string(round(`3_sd',0.1)) _column(50) string(round(`3_t',0.01)) _column(65) string(round(`3_tad',0.1)) _column(80) string(round((`3_pp'/`3_tad')*100,0.1))
    noisily display _column(1) ">= 10+1" _column(20)"`4_n'" _column(30) string(round(`4_pp',0.1)) _column(40) string(round(`4_sd',0.1)) _column(50) string(round(`4_t',0.01)) _column(65) string(round(`4_tad',0.1)) _column(80) string(round((`4_pp'/`4_tad')*100,0.1))

  • #2
    See Ian Watson's -tabout- available from SSC.
    Richard T. Campbell
    Emeritus Professor of Biostatistics and Sociology
    University of Illinois at Chicago

    Comment


    • #3
      Originally posted by Dick Campbell View Post
      See Ian Watson's -tabout- available from SSC.
      Dear Richard,
      thank you very much for your comment. I have to be more specific in explaining my issue. As I am jointly using estimates from sum, tabstat, tabdisp commands in a self-constructed table, I would be interested in a) finding a nicer way to construct this table, and b) export it to tex in a way such as tabout and logout do. If this is working with tabout, how?

      Best regards
      Christian

      Comment

      Working...
      X