Announcement

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

  • What does the "e" option do with the predict command? How does it differ from the residuals option?

    When I run my fixed effects regression model:

    xtreg y var1... varn, fe cluster(id)

    and predict residuals using:
    predict u, e

    or alternatively:
    predict u, residuals

    I get answers that differ somewhat, but not a ton. What is the difference between these two methods of predicting residuals and when should I use each?


  • #2
    Mostly resolved. I recognize that the e option is actually taking an expected value of y conditioned on xb + u. (Was thinking it had something to do with u_sigma and u_e as in this post.) Would still be interested in knowing when you might wish to use this prediction option rather than the standard xb. Or is it exactly the same if no a or b is specified?

    Comment


    • #3
      Elijah:
      -xtreg postestimation- options can give you back the panel-wise effect (u_i) and the systematic error (e_it).
      See the following toy-example (that makes the untested assumption that the -fe- specification is the way to go):
      Code:
      . use "https://www.stata-press.com/data/r16/nlswork.dta"
      (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
      
      . xtreg ln_wage c.age##c.age, fe vce(cluster idcode)
      
      Fixed-effects (within) regression               Number of obs     =     28,510
      Group variable: idcode                          Number of groups  =      4,710
      
      R-sq:                                           Obs per group:
           within  = 0.1087                                         min =          1
           between = 0.1006                                         avg =        6.1
           overall = 0.0865                                         max =         15
      
                                                      F(2,4709)         =     507.42
      corr(u_i, Xb)  = 0.0440                         Prob > F          =     0.0000
      
                                   (Std. Err. adjusted for 4,710 clusters in idcode)
      ------------------------------------------------------------------------------
                   |               Robust
           ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
      -------------+----------------------------------------------------------------
               age |   .0539076    .004307    12.52   0.000     .0454638    .0623515
                   |
       c.age#c.age |  -.0005973    .000072    -8.30   0.000    -.0007384   -.0004562
                   |
             _cons |    .639913   .0624195    10.25   0.000     .5175415    .7622845
      -------------+----------------------------------------------------------------
           sigma_u |   .4039153
           sigma_e |  .30245467
               rho |  .64073314   (fraction of variance due to u_i)
      ------------------------------------------------------------------------------
      
      . predict u_i, u
      (24 missing values generated)
      
      . predict e_it, e
      (24 missing values generated)
      
      . list u_i e_it if idcode==1
      
             +----------------------+
             |      u_i        e_it |
             |----------------------|
          1. | .4181869   -.3836936 |
          2. | .4181869   -.8380948 |
          3. | .4181869   -.3073495 |
          4. | .4181869   -.1464718 |
          5. | .4181869   -.2049846 |
             |----------------------|
          6. | .4181869   -.2537888 |
          7. | .4181869     .438062 |
          8. | .4181869    .4524961 |
          9. | .4181869    .2650439 |
         10. | .4181869     .427596 |
             |----------------------|
         11. | .4181869    .3232167 |
         12. | .4181869    .2279684 |
             +----------------------+
      
      .
      As expected, the panel-wise effect does not change within the same panel, whereas the systematic error does across data waves.
      Kind regards,
      Carlo
      (Stata 19.0)

      Comment


      • #4
        Thank you Carlo! This is extremely helpful. Looks like predict, e is the way to go. Are these residuals standardized? (Is there a way to standardize if not?)

        Comment


        • #5
          Elijah:
          no, those residualls are not standardized.
          Moreover, Stata -predict- suite after -xtreg- does not include any built-in option for standardized residuals (this may have been done for good statistical reasons that I do not know).
          Provided that I never challenged myself with standardized residuals after -xtreg-, a temptative approach follows:
          Code:
          use "https://www.stata-press.com/data/r16/nlswork.dta"
          
          . xtreg ln_wage c.age##c.age, fe vce(cluster idcode)
          
          Fixed-effects (within) regression               Number of obs     =     28,510
          Group variable: idcode                          Number of groups  =      4,710
          
          R-sq:                                           Obs per group:
               within  = 0.1087                                         min =          1
               between = 0.1006                                         avg =        6.1
               overall = 0.0865                                         max =         15
          
                                                          F(2,4709)         =     507.42
          corr(u_i, Xb)  = 0.0440                         Prob > F          =     0.0000
          
                                       (Std. Err. adjusted for 4,710 clusters in idcode)
          ------------------------------------------------------------------------------
                       |               Robust
               ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                   age |   .0539076    .004307    12.52   0.000     .0454638    .0623515
                       |
           c.age#c.age |  -.0005973    .000072    -8.30   0.000    -.0007384   -.0004562
                       |
                 _cons |    .639913   .0624195    10.25   0.000     .5175415    .7622845
          -------------+----------------------------------------------------------------
               sigma_u |   .4039153
               sigma_e |  .30245467
                   rho |  .64073314   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          
          . predict e_it, e
          (24 missing values generated)
          
          . mean e_it
          
          Mean estimation                   Number of obs   =     28,510
          
          --------------------------------------------------------------
                       |       Mean   Std. Err.     [95% Conf. Interval]
          -------------+------------------------------------------------
                  e_it |   3.98e-12   .0016366     -.0032078    .0032078
          --------------------------------------------------------------
          
          . g std_eit= e_it/.0016366
          (24 missing values generated)
          
          . list e_it std_eit if idcode==1
          
                 +-----------------------+
                 |      e_it     std_eit |
                 |-----------------------|
              1. | -.3836936   -234.4455 |
              2. | -.8380948    -512.095 |
              3. | -.3073495   -187.7976 |
              4. | -.1464718   -89.49763 |
              5. | -.2049846   -125.2503 |
                 |-----------------------|
              6. | -.2537888   -155.0707 |
              7. |   .438062    267.6659 |
              8. |  .4524961    276.4855 |
              9. |  .2650439    161.9479 |
             10. |   .427596    261.2709 |
                 |-----------------------|
             11. |  .3232167    197.4928 |
             12. |  .2279684    139.2939 |
                 +-----------------------+
          
          .
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment

          Working...
          X