Announcement

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

  • why is sigma u in xtreg output different from standard deviation of predicted u?

    Dear Statalist,
    my question concerns how xtreg calculates sigma u (and sigma e). My idea was that sigma u is the standard deviation of u. But when I predict the u with the predict postestimation command, and then ask for standard deviation using summarize I get a number different from sigma u in the xtreg output. Why?
    Furthermore, when I calculate the ICC in an ANOVA fashion (code provided below), i.e. SSB/SSW+SSB I get a similar but still different value than rho in the xtreg output. Why?
    I provide the data (which is generated data using rnormal) and a list of commands for replication of what I did.
    Kind regards, Katarzyna

    Code:
    * Example generated by -dataex-. For more info, type help dataex
    clear
    input float result
      54.4773
     48.74695
     77.07542
      64.7085
     95.48249
     54.09767
     80.53448
     55.39391
     54.34201
     65.56054
     42.70115
     65.54634
     44.12673
     53.39897
     82.55605
     63.11832
     52.41323
     61.91088
     78.43945
     57.30145
     21.37305
     48.21943
     85.63551
     84.51431
    33.619602
     69.19332
     63.55545
     62.24532
      73.2518
     60.65511
     60.29387
     53.87441
     42.28486
     64.07081
     67.38633
     48.02635
     43.04099
     93.99119
     58.77192
     88.25754
     55.99929
     45.92612
     60.34822
     71.17495
    70.307594
     53.73354
     63.25698
     52.06905
     56.19698
     70.90791
    end
    Code:
    sort res
    gen school=1 in 1/20
    replace school=2 in 21/35
    replace school=3 in 36/50
    *introduce some variability
    foreach u in 19 16 13 {
    replace school=2 in `u'
    }
    foreach u in 15 20 27 31 38 {
    replace school=3 in `u'
    }
    foreach u in 21 26 {
    replace school=1 in `u'
    }
    
    bysort sc: egen mean=mean(res)
    egen grmean=mean(res)
    
    gen sqdiff=(res-mean)^2
    egen ssw=total(sqdif)
    
    gen sqdiffgrmean=(mean-grmean)^2
    egen ssb=total(sqdiffgr)
    
    list ssb ssw in 1
    display 6938.091/(6938.091+4138.738)
    
    xtset sch
    xtreg res, re
    xtreg res, fe
    predict uest, u
    predict eest, e
    sum uest eest
    Code:
    xtreg res, fe
    
    Fixed-effects (within) regression               Number of obs     =         50
    Group variable: school                          Number of groups  =          3
    
    R-squared:                                      Obs per group:
         Within  =      .                                         min =         14
         Between = 0.0001                                         avg =       16.7
         Overall =      .                                         max =         19
    
                                                    F(0, 47)          =       0.00
    corr(u_i, Xb) =      .                          Prob > F          =          .
    
    ------------------------------------------------------------------------------
          result | Coefficient  Std. err.      t    P>|t|     [95% conf. interval]
    -------------+----------------------------------------------------------------
           _cons |   61.48227   1.327089    46.33   0.000     58.81252    64.15203
    -------------+----------------------------------------------------------------
         sigma_u |  13.890912
         sigma_e |  9.3839355
             rho |  .68664295   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    F test that all u_i=0: F(2, 47) = 39.39                      Prob > F = 0.0000
    
    . predict uest, u
    
    . predict eest, e
    
    . sum uest eest
    
        Variable |        Obs        Mean    Std. dev.       Min        Max
    -------------+---------------------------------------------------------
            uest |         50   -4.29e-08    11.89932   -14.3086   13.46764
            eest |         50    2.59e-08    9.190431  -25.80062   20.53258

  • #2
    Katarzyna:
    the Methods and formula section of the -xtreg- entry in Stata .pdf manual can give you some clues on that.
    Kind regards,
    Carlo
    (StataNow 18.5)

    Comment


    • #3
      One thing to note is that you are running descriptive statistics on uest and it is giving you 50 observations. In your regression model, you only have three schools. This means that you only have 3 values of u. So to get the observed distribution of uest, I would use egen's tag function and re-run the summary command:
      Code:
      bysort school: egen pick1sch = tag(school)
      sum uest if pick1sch==1

      Comment


      • #4
        Thanks Erik, that's right of course.

        Comment

        Working...
        X