Announcement

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

  • Feature or bug: No r(table) after running a mixed model with multiple imputation

    I am running a mixed model on multiple imputed data and would like to extract the results via r(table) for reporting. I am not getting r(table) outputted however. This is different to other commands, eg regress, or when running mixed without muliple imputation. Below is a reproducible example (I am running v18.0 on Mac osx).

    Does anyone know if this an ommision in Stata or a feature due to some quirk of combining multiple imputation and mixed models?

    Code:
    version 18.0
    
    clear
    set obs 10000
    
    gen x = rnormal(0,1)
    gen cluster = round(_n/1000)
    gen y = rnormal(0,1) + x + cluster
    
    replace x = . if _n < 1000
    
    mi set wide
    mi register imputed y x
    mi impute mvn y x, add(5)
    
    regress y x
    mat list r(table) // shows a table
    
    mi estimate: regress y x
    mat list r(table) // shows a table
    
    mixed y x || cluster:
    mat list r(table) // shows a table
    
    
    mi estimate: mixed y x || cluster:
    mat list r(table) // error: matrix r(table) not found
    
    return list // an empty return
    Last edited by Gordon Forbes; 27 Sep 2024, 06:30.

  • #2
    I don't know about this specific issue, Gordon. However, I have successfully used mixed with multiply imputed data and the estout set of commands (from SSC) to create tables of model results. To do so, you have to add the post option to mi estimate.
    Code:
    version 18.0
    
    clear
    set obs 10000
    
    gen x = rnormal(0,1)
    gen cluster = round(_n/1000)
    gen y = rnormal(0,1) + x + cluster
    
    replace x = . if _n < 1000
    
    mi set wide
    mi register imputed y x
    mi impute mvn y x, add(5)
    
    mi estimate, post: mixed y x || cluster:
    
    eststo m1 
    
    esttab m1, se wide b(3) replace ///
        transform(ln*: exp(@) exp(@)) //

    Comment


    • #3
      I can confirm that the same thing happens on my setup, StataNow 18.5 MP4 on Windows 10 64-bit.

      I can't think of any reason why r(table) would be invalid in this context. I do understand that it could not be calculated in exactly the same way that it is done in the non-mi context, but I'm sure it is within the ability of StataCorp's programmers to code around this problem as they have done so for regress. So I think this is a bug, and I suggest contacting TechSupport about this.

      Added: Crossed with #2. I find that adding the -post- option to -mi estimate- does not solve this problem.

      Code:
      . mi estimate, post: mixed y x || cluster:
      
      Multiple-imputation estimates                   Imputations       =          5
      Mixed-effects ML regression                     Number of obs     =     10,000
      
      Group variable: cluster                         Number of groups  =         11
                                                      Obs per group:
                                                                    min =        499
                                                                    avg =      909.1
                                                                    max =      1,000
                                                      Average RVI       =     0.1493
                                                      Largest FMI       =     0.2926
      DF adjustment:   Large sample                   DF:     min       =      55.83
                                                              avg       =   4.77e+09
                                                              max       =   1.83e+10
      Model F test:       Equal FMI                   F(   1,   55.8)   =    5513.54
                                                      Prob > F          =     0.0000
      
      ------------------------------------------------------------------------------
                 y | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
      -------------+----------------------------------------------------------------
                 x |   .9299334   .0125238    74.25   0.000     .9048435    .9550233
             _cons |   5.061363    .930292     5.44   0.000     3.238024    6.884701
      ------------------------------------------------------------------------------
      
      ------------------------------------------------------------------------------
        Random-effects parameters  |   Estimate   Std. err.     [95% conf. interval]
      -----------------------------+------------------------------------------------
      cluster: Identity            |
                         sd(_cons) |   3.085179   .6578957      2.031266     4.68591
      -----------------------------+------------------------------------------------
                      sd(Residual) |   1.071551   .0084128      1.055013    1.088348
      ------------------------------------------------------------------------------
      
      . mat list r(table) // error: matrix r(table) not found
      matrix r(table) not found
      r(111);
      Also Added: The -help file- for -mi estimate- specifically states that r(table) is returned and it mentions no exceptions. So this is definitely a bug.
      Last edited by Clyde Schechter; 27 Sep 2024, 10:44.

      Comment


      • #4
        Thanks Erik and Clyde for your responses - very helpful

        Comment


        • #5
          Gordon has found a bug in mi estimate:mixed; and so, Clyde is correct. mi estimate:mixed should return the r(table) matrix. We will fix this in a future update to Stata.

          Comment

          Working...
          X