Announcement

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

  • Accessing the random effect residuals in a "mixed" command

    Tl;dr: Where are the "var(_cons)" and "var(Residual)" stored after a mixed estimation?

    In my current analysis, I'm assessing some level 1 (individuals) and level 2 (countries) variables impact on a DV. In order to estimate the amount of variance that can be attributed to the country and individual level, I first run a "bare bones" model.

    Code:
    mixed Amental_healthN1 || Country:, ml variance robust
    Then I can calculate the variance attributed to the 2nd level by "var(_cons)" / ("var(_cons)" + "var(Residual)"). For my current analysis, this comes out to 0.1138989 / (0.1138989 + 1.777575) = 6.4%. So this is the variance attributed to the country-level. Later on I plan to use the full model to figure out the level of variance explained at level 1 and 2 based on how much residual variance is left after I input the variables.

    While these are relatively simple calculations to do by externally, I would much rather do something akin to

    Code:
    **PSEUDOCODE
    display "var(_cons)" / ("var(_cons)" +  "var(Residual)").
    But I cannot find where these are stored in Stata. I've been searching the "return list" and "ereturn list" commands, the documentation, and the forums for this information, but I cannot locate them. Hope someone can point me in the right direction. Thanks.

  • #2
    -mixed- has a postestimation command to compute the ICC directly, which you seem to want but do not outright name. The random effects parameters can also be accessed more easily by issuing the second -estat- command.

    Code:
    webuse pig
    mixed weight i.week || id :
    estat icc
    estat sd, var
    Result:

    Code:
    . estat icc
    
    Residual intraclass correlation
    
    ------------------------------------------------------------------------------
                           Level |        ICC   Std. err.     [95% conf. interval]
    -----------------------------+------------------------------------------------
                              id |   .7790722    .038439      .6947778    .8452711
    ------------------------------------------------------------------------------
    
    . estat sd, var
    
    ------------------------------------------------------------------------------
      Random-effects parameters  |   Estimate   Std. err.     [95% conf. interval]
    -----------------------------+------------------------------------------------
    id: Identity                 |
                      var(_cons) |   14.83704    3.12421      9.819998     22.4173
    -----------------------------+------------------------------------------------
                   var(Residual) |   4.207462   .3036474      3.652498    4.846747
    ------------------------------------------------------------------------------
    Edit to add: You also seem to be used a hybrid of old style syntax from -xtmixed- and modern -mixed-. The modern command is -mixed-, which no longer requires -variance-, as you will see variances are displayed by default. Also for robust estimation, you should use -vce()-, either as -vce(robust)- or -vce(cluster cluster_id)- for cluster-robust standard errors.
    Last edited by Leonardo Guizzetti; 13 Jan 2023, 07:41.

    Comment

    Working...
    X