Announcement

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

  • Subpop MLM: Xtmixed


    Hi all,
    I am running a multi-level modeling using complex survey data, which used a stratified, clustered, and unequally sampling design. For my research questions, I have to select a subsample, but due to the weight issues, I think I am not able to create a new tiny dataset which only includes my subsample. For regular regression analyses, I use SVY, subpop (): regress command, but I wonder if it would be possible to use a similar command for MLM with a subpop and continuous outcomes in Stata. If not possible, any thoughts on another approach to deal with it?

    Thank you so much!


  • #2
    meglm allows the svy prefix.

    There is an example of a two-level logistic regression model in the manual entry.

    Here is a simulated two-level linear regression example:

    Code:
    set seed 12345
    * 3 strata
    set obs 3
    gen sid = _n
    * 100 psus per stratum
    expand 100
    gen uid = _n
    gen u = rnormal()
    gen w1 = runiformint(2,4)
    * 20 individuals per psu
    expand 20
    gen w2 = runiformint(2,4)
    gen x = rnormal()
    gen y = 1 - x + u + rnormal()
    * select a subpop
    gen sub = runiform() > .3
    
    svyset uid, strata(sid) weight(w1) || _n, weight(w2)
    
    svy, subpop(sub) : meglm y x || uid:
    Here is a log of the results from running the above in Stata 15:

    Code:
    . set seed 12345
    
    . * 3 strata
    . set obs 3
    number of observations (_N) was 0, now 3
    
    . gen sid = _n
    
    . * 100 psus per stratum
    . expand 100
    (297 observations created)
    
    . gen uid = _n
    
    . gen u = rnormal()
    
    . gen w1 = runiformint(2,4)
    
    . * 20 individuals per psu
    . expand 20
    (5,700 observations created)
    
    . gen w2 = runiformint(2,4)
    
    . gen x = rnormal()
    
    . gen y = 1 - x + u + rnormal()
    
    . * select a subpop
    . gen sub = runiform() > .3
    
    . 
    . svyset uid, strata(sid) weight(w1) || _n, weight(w2)
    Note: Stage 1 is sampled with replacement; further stages will be ignored for
          variance estimation.
    
          pweight: <none>
              VCE: linearized
      Single unit: missing
         Strata 1: sid
             SU 1: uid
            FPC 1: <zero>
         Weight 1: w1
         Strata 2: <one>
             SU 2: <observations>
            FPC 2: <zero>
         Weight 2: w2
    
    . 
    . svy, subpop(sub) : meglm y x || uid:
    (running meglm on estimation sample)
    
    Survey: Mixed-effects GLM
    
    Number of strata   =         3                  Number of obs     =      6,000
    Number of PSUs     =       300                  Population size   =     55,851
                                                    Subpop. no. obs   =      4,165
                                                    Subpop. size      =     38,967
                                                    Design df         =        297
                                                    F(   1,    297)   =    3289.50
                                                    Prob > F          =     0.0000
    
    ------------------------------------------------------------------------------
                 |             Linearized
               y |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
               x |  -.9973098   .0173886   -57.35   0.000     -1.03153   -.9630893
           _cons |   1.129561   .0623665    18.11   0.000     1.006825    1.252297
    -------------+----------------------------------------------------------------
    uid          |
       var(_cons)|   1.066697   .0882144                      .9064834    1.255227
    -------------+----------------------------------------------------------------
         var(e.y)|   .9495035   .0249011                      .9017416     .999795
    ------------------------------------------------------------------------------

    Comment


    • #3
      Thank you so much. It was very helpful. However, I wonder if you know how to estimate ICC and AIC. I tried est ic and est gof, but both did not work. If I need to calculate ICC, it seems the formula for meglm is different from the formula for xtmixed models, right?

      Comment

      Working...
      X