Announcement

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

  • problem with collect layout

    Hello Statalisters,

    I'm having an issue obtaining the table that I want using collect with mi estimate and this issue only comes up with factor variables and not continuous ones.

    I run the following :

    Code:
    collect clear
    collect TR=_r_b SE=_r_se Lower=_r_lb Upper=_r_ub Pvalue=_r_p, ///
        :streg ib1.pbq_sex,vce(cluster team) dist(loglogistic) nolog tr
    collect dims
    collect levelsof result
    collect style cell result, nformat(%6.3f)
    collect layout (colname) (result)
    output is shown below:

    Code:
    . collect clear
    
    . collect TR=_r_b SE=_r_se Lower=_r_lb Upper=_r_ub Pvalue=_r_p, ///
    >         :streg ib1.pbq_sex,vce(cluster team) dist(loglogistic) nolog tr
    
             Failure _d: injuryr1==1 2 3 9
       Analysis time _t: (enddate-origin)
                 Origin: time rtpdate
      Exit on or before: time enddate
    
    Loglogistic AFT regression
    
    No. of subjects =    15,648                             Number of obs = 15,648
    No. of failures =     2,979
    Time at risk    = 1,213,389
                                                            Wald chi2(1)  =   5.28
    Log pseudolikelihood = -6890.3172                       Prob > chi2   = 0.0215
    
                                     (Std. err. adjusted for 313 clusters in team)
    ------------------------------------------------------------------------------
                 |               Robust
              _t | Time ratio   std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         pbq_sex |
         Female  |    1.77584   .4437184     2.30   0.022     1.088226    2.897933
           _cons |   163.0145   11.89825    69.79   0.000     141.2856    188.0851
    -------------+----------------------------------------------------------------
        /lngamma |  -.9076884   .1276073    -7.11   0.000    -1.157794   -.6575827
    -------------+----------------------------------------------------------------
           gamma |   .4034558   .0514839                      .3141784    .5181022
    ------------------------------------------------------------------------------
    Note: Estimates are transformed only in the first equation to time ratios.
    Note: _cons estimates baseline time.
    
    . collect dims
    
    Collection dimensions
    Collection: default
    -----------------------------------------
                       Dimension   No. levels
    -----------------------------------------
    Layout, style, header, label
                          cmdset   1         
                           coleq   3         
                         colname   5         
               colname_remainder   1         
                         pbq_sex   2         
                   program_class   2         
                          result   56        
                     result_type   3         
                         rowname   1         
    
    Style only
                    border_block   4         
                       cell_type   4         
    -----------------------------------------
    
    . collect levelsof result
    
    Collection: default
     Dimension: result
        Levels: Lower N N_clust N_fail N_sub Pvalue SE TR Upper _r_b _r_ci _r_df _r_lb _r_p _r_se _r_ub _r_z
                _r_z_abs chi2 chi2type clustvar cmd cmd2 cmdline converged dead depvar df_m frm2 gamma ic k
                k_aux k_dv k_eq k_eq_model ll ll_0 ml_method opt p predict predict_sub properties rank rank0
                rc risk stcurve t0 technique title user vce vcetype which
    
    . collect style cell result, nformat(%6.3f)
    
    . collect layout (colname) (result)
    
    Collection: default
          Rows: colname
       Columns: result
       Table 1: 4 x 5
    
    -------------------------------------------------
              |      TR     SE   Lower   Upper Pvalue
    ----------+--------------------------------------
    Female    |   1.776  0.444   1.088   2.898  0.022
    Male      |   1.000  0.000       .       .      .
    lngamma   |  -0.908  0.128  -1.158  -0.658  0.000
    Intercept | 163.014 11.898 141.286 188.085  0.000
    -------------------------------------------------
    
    .

    this is fine i can work with that table.

    The issue arises when I am trying to use this in combination with mi estimate:
    Code:
    . collect clear
    
    . collect _r_b _r_se _r_lb _r_ub _r_p ///
    >         :mi estimate,dots eform(Time ratio) cmdok:streg ib1.pbq_sex,vce(cluster team) dist(loglogistic) n
    > olog
    
    Imputations (50):
      .........10.........20.........30.........40.........50 done
    
    Multiple-imputation estimates                   Imputations       =         50
    Loglogistic AFT regression                      Number of obs     =        448
                                                    Average RVI       =     0.0000
                                                    Largest FMI       =     0.0000
    DF adjustment:   Large sample                   DF:     min       =   4.84e+61
                                                            avg       =   4.84e+61
                                                            max       =          .
    Model F test:       Equal FMI                   F(   1,      .)   =       2.23
    Within VCE type:       Robust                   Prob > F          =     0.1353
    
                                    (Within VCE adjusted for 313 clusters in team)
    ------------------------------------------------------------------------------
              _t | Time ratio   Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
         pbq_sex |
         Female  |    1.43824   .3499714     1.49   0.135     .8927003    2.317164
           _cons |   174.1712   12.62802    71.17   0.000     151.0989    200.7666
    -------------+----------------------------------------------------------------
        /lngamma |  -.8595957    .112937    -7.61   0.000    -1.080948   -.6382433
    -------------+----------------------------------------------------------------
           gamma |   .4233332     .04781                      .3392737    .5282196
    ------------------------------------------------------------------------------
    Note: Estimates are transformed only in the first equation to time ratios.
    Note: _cons estimates baseline time.
    
    . collect dims
    
    Collection dimensions
    Collection: default
    -----------------------------------------
                       Dimension   No. levels
    -----------------------------------------
    Layout, style, header, label
                          cmdset   1         
                           coleq   2         
                         colname   9         
               colname_remainder   1         
                         pbq_sex   2         
                   program_class   1         
                          result   99        
                     result_type   3         
                           roweq   2         
                         rowname   5         
    
    Style only
                    border_block   4         
                       cell_type   4         
    -----------------------------------------
    
    . collect levelsof result
    
    Collection: default
     Dimension: result
        Levels: B_mi Cns_mi F_mi M_mi N N_clust N_clust_mi N_fail N_max_mi N_mi N_min_mi N_sub N_sub_mi V_mi
                W_mi _dfnote_mi _predict_mi _sortseed_mi _sortseedcmd_mi b_mi chi2 chi2type cilevel_mi
                clustvar cmd cmd_mi cmdline cmdline_mi consonly converged converged_cons crittype dead depvar
                df_avg_mi df_c_mi df_m df_m_mi df_max_mi df_mi df_min_mi df_r_mi dfadjust_mi diparm1 ecmd2_mi
                ecmd_mi esampvary_mi fmi_max_mi fmi_mi frm2 gamma ic k k_autoCns k_aux k_dv k_eq k_eq_model
                k_eq_model_mi k_exp_mi ll ll_0 m_est_mi m_mi marginsfootnote marginsprop mcerror_mi mi
                ml_method modeltest_mi noconstant opt p p_mi pise_mi predict_sub prefix_mi rank rank0 rc
                rc_mi re_mi reparm_rc_mi risk rvi_avg_F_mi rvi_avg_mi rvi_mi singularHmethod stcurve t0
                technique title title_mi ufmi_mi user vce vcetype which wvce_mi
    
    . collect style cell result, nformat(%6.3f)
    
    . collect layout (colname) (result)
    
    Collection: default
          Rows: colname
       Columns: result
    
    Your layout specification does not identify any items.
    I notice that the _r_b series are not in the result dimensions with mi estimates using a factor variable but when I use a continuous variable with mi estimate they are indeed there and I get the table that I want...

    I'd love to know what I'm doing wrong.

    Regards,

    Jean-Michel

  • #2
    Could you post a reproducible example? Your first example suggests that it should work fine.

    Comment


    • #3
      Seems the post option to mi estimate is lacking in #1 (also see -etable-)
      Code:
      clear all
      webuse mheart1s20
      qui mi estimate, post : logit attack i.smokes age
      
      collect get _r_b _r_se _r_ci  
      collect layout (colname) (result) 
       
      mi est, noheader
      Code:
      . collect layout (colname) (result) 
      
      Collection: default
            Rows: colname
         Columns: result
         Table 1: 4 x 3
      
      -------------------------------------------------------------
                       | Coefficient Std. error        95% CI      
      -----------------+-------------------------------------------
      Current smoker=0 |           0          0                    
      Current smoker=1 |     1.14354   .3458387  .4657091  1.821372
      Age, in years    |    .0313176   .0148138   .002283  .0603521
      Intercept        |   -2.470375    .879083 -4.193346 -.7474037
      -------------------------------------------------------------
      
      .  
      . mi est, noheader 
      
      ------------------------------------------------------------------------------
            attack | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
          1.smokes |    1.14354   .3458387     3.31   0.001     .4657091    1.821372
               age |   .0313176   .0148138     2.11   0.035      .002283    .0603521
             _cons |  -2.470375    .879083    -2.81   0.005    -4.193346   -.7474037
      ------------------------------------------------------------------------------

      Comment


      • #4
        Thank you Bjarte, that has indeed solved the issue.

        Code:
        . collect _r_b _r_se _r_lb _r_ub _r_p :mi estimate,post dots eform(Time ratio) cmdok:streg ib1.pbq_sex,vce(cluster team) dist(loglogistic) nolog
        
        . collect layout (colname) (result)
        
        Collection: default
              Rows: colname
           Columns: result
           Table 1: 5 x 5
        
        --------------------------------------------------------------------------
                  | Coefficient Std. error 95% lower bound 95% upper bound p-value
        ----------+---------------------------------------------------------------
        Female    |     1.43824   .3499714        .8927003        2.317164   0.135
        Male      |           1          0                                        
        lngamma   |   -.8595957    .112937       -1.080948       -.6382433   0.000
        gamma     |    .4233332     .04781        .3392737        .5282196        
        Intercept |    174.1712   12.62802        151.0989        200.7666   0.000
        --------------------------------------------------------------------------
        I really appreciate this.

        Regards,

        Jean-Michel Galarneau

        Comment

        Working...
        X