Announcement

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

  • weighted random effects model with clustered SE

    Hello:

    I want to estimated a weighted RE model with clustered standard errors. The xtreg does not allow weights with the re option. The xtregre2 allows weights but not clustering of SE. What are my options? Is there any command that will allow me to estimate a weighted RE model with clustered standard errors?

    Thanks

  • #2
    -mixed- will cluster the standard errors if you used pweights, or you could use -vce(cluster var)- if you use fweights. For example:

    Code:
    . webuse nlswork,clear
    (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
    
    . 
    . drop if grade == 0
    (21 observations deleted)
    
    . 
    . mixed ln_wage age  [pw= grade] || idcode: ,   stddev   pw(grade) nolog pwscale(size)
    
    Mixed-effects regression                        Number of obs     =     28,487
    Group variable: idcode                          Number of groups  =      4,700
                                                    Obs per group:
                                                                  min =          1
                                                                  avg =        6.1
                                                                  max =         15
                                                    Wald chi2(1)      =    1060.42
    Log pseudolikelihood = -144650.68               Prob > chi2       =     0.0000
    
                                 (Std. err. adjusted for 4,700 clusters in idcode)
    ------------------------------------------------------------------------------
                 |               Robust
         ln_wage | Coefficient  std. err.      z    P>|z|     [95% conf. interval]
    -------------+----------------------------------------------------------------
             age |   .0190463   .0005849    32.56   0.000        .0179    .0201927
           _cons |   1.146902   .0164237    69.83   0.000     1.114712    1.179092
    ------------------------------------------------------------------------------
    
    ------------------------------------------------------------------------------
                                 |               Robust           
      Random-effects parameters  |   Estimate   std. err.     [95% conf. interval]
    -----------------------------+------------------------------------------------
    idcode: Identity             |
                       sd(_cons) |   .3643255   .0051169      .3544333    .3744938
    -----------------------------+------------------------------------------------
                    sd(Residual) |    .305044   .0037289      .2978223    .3124409
    ------------------------------------------------------------------------------

    Comment


    • #3
      Mywish:
      welcome to this forum.
      As an aside to Scott's helpful reply, you may want to consider -mixed- cousin -xtreg, re mle- (that allows -iweight-, though):
      Code:
      . use "https://www.stata-press.com/data/r17/nlswork.dta"
      (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
      
      . xtreg ln_wage age [iweight = nev_mar], mle
      
      Fitting constant-only model:
      Iteration 0:   log likelihood = -2896.4449
      Iteration 1:   log likelihood = -2879.4203
      Iteration 2:   log likelihood = -2879.0314
      Iteration 3:   log likelihood = -2879.0311
      
      Fitting full model:
      Iteration 0:   log likelihood = -2323.9484
      Iteration 1:   log likelihood = -2319.7536
      Iteration 2:   log likelihood = -2319.6975
      Iteration 3:   log likelihood = -2319.6975
      
      Random-effects ML regression                        Number of obs    =   6,548
      Group variable: idcode                              Number of groups =   1,972
      
      Random effects u_i ~ Gaussian                       Obs per group:
                                                                       min =       1
                                                                       avg =     3.3
                                                                       max =      15
      
                                                          LR chi2(1)       = 1118.67
      Log likelihood = -2319.6975                         Prob > chi2      =  0.0000
      
      ------------------------------------------------------------------------------
           ln_wage | Coefficient  Std. err.      z    P>|z|     [95% conf. interval]
      -------------+----------------------------------------------------------------
               age |   .0290693   .0008328    34.90   0.000      .027437    .0307016
             _cons |   .8884023   .0213848    41.54   0.000     .8464889    .9303158
      -------------+----------------------------------------------------------------
          /sigma_u |   .3279617   .0068033                      .3148948    .3415708
          /sigma_e |   .2732508   .0028178                      .2677834    .2788298
               rho |   .5902535   .0117491                       .567083     .613113
      ------------------------------------------------------------------------------
      LR test of sigma_u=0: chibar2(01) = 3267.48            Prob >= chibar2 = 0.000
      
      .
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment


      • #4
        Thanks, Scott and Carlo for these helpful tips. Will try these options, and read more about them to decide which one is best for the data and study objective.

        Thanks again.
        Mywish

        Comment


        • #5
          Mywish:
          take a look at -help weight- for a detailed description of different -weight- allowed.
          For instance -pweight- (as per Scott's helpful example) differ from -iweight- (and -mixed- support -fweight-, too, whereas neither .xtreg, re mle-, nor -mixed- support -aweight-).
          Last edited by Carlo Lazzaro; 02 Feb 2022, 10:29.
          Kind regards,
          Carlo
          (StataNow 18.5)

          Comment

          Working...
          X