Announcement

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

  • dtable, adding results from stci.

    I have no problem adding confidence intervals from mean to dtable, but I am unable to add them from stci:

    Code:
    webuse page2, clear
    sort group
    dtable time, by(group, nototal)
    by group: collect: stci, by(group)
    collect composite define _r_ci = _r_lb _r_ub, trim
    collect style cell result[_r_ci], sformat("[%s]")
    collect style autolevels result _r_ci
    collect layout (colname) (group#result)
    collect preview
    and the result is:
    Code:
    . collect preview
    
    --------------------------------------
                       group              
                 1                2       
    --------------------------------------
    time 215.526 (36.127) 239.190 (52.347)
    --------------------------------------
    rather than:
    Code:
    . stci, by(group)
    
            Failure _d: dead
      Analysis time _t: time
    
                 | Number of
    group        |  subjects         50%      Std. err.    [95% conf. interval]
    -------------+-------------------------------------------------------------
               1 |        19         216      7.661029          190        234
               2 |        21         233      3.081611          232        280
    -------------+-------------------------------------------------------------
           Total |        40         232      2.562933          213        239
    I would be grateful for any advice on what I am doing wrong. Ideally I only want the group variables and not the total.

    Thanks.
    Julie

  • #2
    Perhaps something like this:

    Code:
    collect clear
    webuse page2, clear
    bys group: collect: stci
    collect style cell result[N_sub p50 lb ub],  nformat(%4.0f)
    collect style cell result[se], nformat(%4.3f)
    collect style cell result, halign(center)
    collect composite define _r_ci = lb ub, trim
    collect style cell result[_r_ci], sformat("[%s]")
    collect label levels result p50 "50%" se "Std. err." _r_ci "95% CI", modify
    collect style header result, title(hide) level(label)
    collect style header group, title(label)
    collect style autolevels result N_sub p50 se _r_ci, clear
    collect layout (group) (result)
    which produces:

    Code:
    . collect preview
    
    --------------------------------------------------
          | Number of subjects 50% Std. err.  [95% CI]
    ------+-------------------------------------------
    group |                                          
      1   |         19         216   7.661   [190 234]
      2   |         21         233   3.082   [232 280]
    --------------------------------------------------
    Last edited by Hemanshu Kumar; 10 Mar 2025, 10:25.

    Comment


    • #3
      Thank you so much for your help.
      Julie.

      Comment

      Working...
      X