Announcement

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

  • Residuals in a panel data model

    Hi
    I am running a regression (using panel data) looking at the effect of income on food consumption and controlling for age. I am trying to determine if I need a squared term for age so wish to create a scatter plot of residuals against my independent variable as I have read this will show if there is a non- linear relationship- is this correct?
    Therefore do I run:
    xtreg fruvege age_dv, fe robust
    predict fit, xbu
    gen fit_2=fit^2
    xtreg fruvege age_dv fit_2, fe robust
    test fit_2=0

    twoway (scatter fit_2 lnm)

    in which case I get this:



    What does this mean? what am I doing wrong?
    Thank you for any help.

  • #2
    Alex:
    it would seem that you're interested in a Pregibon test (https://www.jstor.org/stable/2346405):
    Code:
    xtreg  fruvege fit fit^2, fe robust
    test sq_fit
    If -test- turns out to be significant, your model is misspecified.
    A toy-example of a misspecified model is reported below:
    Code:
    . use "http://www.stata-press.com/data/r15/nlswork.dta"
    (National Longitudinal Survey.  Young Women 14-26 years of age in 1968)
    
    . xtreg ln_wage age
    
    Random-effects GLS regression                   Number of obs     =     28,510
    Group variable: idcode                          Number of groups  =      4,710
    
    R-sq:                                           Obs per group:
         within  = 0.1026                                         min =          1
         between = 0.0877                                         avg =        6.1
         overall = 0.0774                                         max =         15
    
                                                    Wald chi2(1)      =    3140.35
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             age |   .0185667   .0003313    56.04   0.000     .0179174    .0192161
           _cons |   1.120439   .0112038   100.01   0.000      1.09848    1.142398
    -------------+----------------------------------------------------------------
         sigma_u |  .36972456
         sigma_e |  .30349389
             rho |  .59743613   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . predict fit, xb
    (24 missing values generated)
    
    . g sq_fit=fit^2
    (24 missing values generated)
    
    . xtreg ln_wage fit sq_fit
    
    Random-effects GLS 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.1015                                         avg =        6.1
         overall = 0.0870                                         max =         15
    
                                                    Wald chi2(2)      =    3388.51
    corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
    
    ------------------------------------------------------------------------------
         ln_wage |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
    -------------+----------------------------------------------------------------
             fit |   7.572907   .4384755    17.27   0.000      6.71351    8.432303
          sq_fit |   -1.96055   .1306854   -15.00   0.000    -2.216689   -1.704412
           _cons |  -5.475764   .3662055   -14.95   0.000    -6.193514   -4.758015
    -------------+----------------------------------------------------------------
         sigma_u |   .3654049
         sigma_e |  .30245467
             rho |  .59342665   (fraction of variance due to u_i)
    ------------------------------------------------------------------------------
    
    . test sq_fit
    
     ( 1)  sq_fit = 0
    
               chi2(  1) =  225.06
             Prob > chi2 =    0.0000
    
    .
    You can investigate your specification further by adding grade 3 and 4 polynomials of -xb- as predictors of your accessory regression.
    Kind regards,
    Carlo
    (Stata 18.0 SE)

    Comment


    • #3
      I will look into this. Many thanks

      Comment


      • #4
        Alex:
        you may also take a look at the really valuable: https://www.stata.com/bookstore/heal...s-using-stata/, Chapter 4.
        Kind regards,
        Carlo
        (Stata 18.0 SE)

        Comment

        Working...
        X