Announcement

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

  • Accessing coefficients with _b[var] after mi estimate

    Dear Stata Forum,

    I would like to access the coefficients from a regression estimated with multiply imputed data. After a normal regression with normal data, I can do this with the with _b[var] construction. However, as shown below, this does not seem to work if the regression has been estimated with the "mi estimate" prefix. Is there an easy way to retrieve individual coefficients after mi estimate?

    Thanks,

    Jeremy

    Code:
    . use http://www.stata-press.com/data/r13/mheart1s20
    (Fictional heart attack data; bmi missing)
    
    .
    . mi estimate: logit attack smokes age bmi hsgrad female
    
    Multiple-imputation estimates                   Imputations       =         20
    Logistic regression                             Number of obs     =        154
                                                    Average RVI       =     0.0312
                                                    Largest FMI       =     0.1355
    DF adjustment:   Large sample                   DF:     min       =   1,060.38
                                                            avg       = 223,362.56
                                                            max       = 493,335.88
    Model F test:       Equal FMI                   F(   5,71379.3)   =       3.59
    Within VCE type:          OIM                   Prob > F          =     0.0030
    
    ------------------------------------------------------------------------------
          attack |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          smokes |   1.198595   .3578195     3.35   0.001     .4972789    1.899911
             age |   .0360159   .0154399     2.33   0.020     .0057541    .0662776
             bmi |   .1039416   .0476136     2.18   0.029      .010514    .1973692
          hsgrad |   .1578992   .4049257     0.39   0.697    -.6357464    .9515449
          female |  -.1067433   .4164735    -0.26   0.798    -.9230191    .7095326
           _cons |  -5.478143   1.685075    -3.25   0.001    -8.782394   -2.173892
    ------------------------------------------------------------------------------
    
    . di _b[female]
    no variables defined
    r(111);
    
    end of do-file
    
    r(111);

  • #2
    Jeremy:
    thanks for providing a reproducible example.
    You may want to access the coefficients you're interested in via -mat list-, as in the following example:
    Code:
    . use http://www.stata-press.com/data/r13/mheart1s20
    (Fictional heart attack data; bmi missing)
    
    . mi estimate: logit attack smokes age bmi hsgrad female
    
    Multiple-imputation estimates                     Imputations     =         20
    Logistic regression                               Number of obs   =        154
                                                      Average RVI     =     0.0312
                                                      Largest FMI     =     0.1355
    DF adjustment:   Large sample                     DF:     min     =    1060.38
                                                              avg     =  223362.56
                                                              max     =  493335.88
    Model F test:       Equal FMI                     F(   5,71379.3) =       3.59
    Within VCE type:          OIM                     Prob > F        =     0.0030
    
    ------------------------------------------------------------------------------
          attack |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
          smokes |   1.198595   .3578195     3.35   0.001     .4972789    1.899911
             age |   .0360159   .0154399     2.33   0.020     .0057541    .0662776
             bmi |   .1039416   .0476136     2.18   0.029      .010514    .1973692
          hsgrad |   .1578992   .4049257     0.39   0.697    -.6357464    .9515449
          female |  -.1067433   .4164735    -0.26   0.798    -.9230191    .7095326
           _cons |  -5.478143   1.685075    -3.25   0.001    -8.782394   -2.173892
    ------------------------------------------------------------------------------
    
    
    
    . mat list e(b_mi)
    
    e(b_mi)[1,6]
            attack:     attack:     attack:     attack:     attack:     attack:
            smokes         age         bmi      hsgrad      female       _cons
    r1   1.1985949   .03601589   .10394161   .15789924  -.10674329  -5.4781425
    Kind regards,
    Carlo
    (Stata 19.0)

    Comment


    • #3
      Another option is specifying the post option with mi estimate. This has potentially serious consequence for anything other than obtaining individual coefficients.

      Best
      Daniel

      Comment


      • #4
        Thank you both for your suggestions. The post option suggested by Daniel makes the _b[var] approach work just fine--thank you for the warning about the potential hazards of using the post option. Accessing the matrix as suggested by Carlo works well too.

        Jeremy

        Comment

        Working...
        X