Announcement

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

  • Autocorrelation "xtserial"

    Hello Stata Community
    I have a problem running the "xtserial" command in my panel data. I get the error message: no observation, maybe because I have 2 years only.
    How can I solve this problem please.

  • #2
    You cannot test for serial correlation with two time periods only.

    Comment


    • #3
      Nermine:
      you can check the relevance of Andrew's helpful explanation via the following toy-example, that elaborates on page 251-253 of A. Cameron, P. Trivedi. Microeconometrics Using Stata. Revised edition. College Station, TX: Stata Press, 2010 (the panel starts at year=68):
      Code:
      . use https://www.stata-press.com/data/r18/nlswork.dta
      (National Longitudinal Survey of Young Women, 14-24 years old in 1968)
      
      . xtset idcode year
      
      Panel variable: idcode (unbalanced)
       Time variable: year, 68 to 88, but with gaps
               Delta: 1 unit
      
      . 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-squared:                                      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 | Coefficient  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 res, e
      (24 missing values generated)
      
      . forvalues i = 68/70 {
        2. quietly corr res L1.res if year==`i'
        3. display "Autocorrelation at lag 1 in year`i' = " %6.3f r(rho)
        4.  }
      no observations;
      
      . forvalues i = 69/70 {
        2. quietly corr res L1.res if year==`i'
        3. display "Autocorrelation at lag 1 in year`i' = " %6.3f r(rho)
        4.  }
      Autocorrelation at lag 1 in year69 =  0.351
      Autocorrelation at lag 1 in year70 =  0.485
      
      
      .
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment

      Working...
      X