Announcement

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

  • Help with xttest1 syntax for RE versus FE

    EDIT: I now realise that the xttest commands are not comparing FE and RE, but rather RE and OLS. Ignore this post, I apologise for the error.

    Hi all. I am estimating a specification that regresses hours worked against the main independent variable LK, various controlling regressors, and year effects. I am using unbalanced panel data, and want to see which of the RE or FE estimators is more appropriate via a Hausman test. Due to the presence of serial correlation I am using clustered errors, so have been advised to use xttest commands. Because my panel is unbalanced, I am using xttest1.

    Because the command is quite old, when including year effects I use the xi prefix:

    Code:
    xi: xtreg hours LK CO PAU EP UB UD ALMP SM i.year, re cluster(CID)
    I then use xttest1 and it works with no problems. However, I'd also like to estimate specifications with a lagged dependent variable. I generated the lagged dependent variable manually, and entered:

    Code:
    xi: xtreg hours lagged_hours LK CO PAU EP UB UD ALMP SM i.year, re cluster(CID)
    However, using xttest1 now gives:

    Code:
    . xttest1
    factor-variable and time-series operators not allowed
    r(101);
    I tried replacing i.year with manually created year dummies, but receive the same error message. I am assuming the issue is including a lagged dependent variable - does anyone have any advice on how to get round this? Thank you.
    Last edited by William Law; 23 Feb 2025, 06:36.

  • #2
    It's not the lag per se, it's the fact the two models are not identical I think. Also, when you have identical models, it won't work with gaps in the data (which you probably have).

    You can use the Mundlak (CRE) approach. If you reject testparm, then FE preferred.

    Code:
    clear
    webuse nlswork , clear
    
    xtset idcode year
    g lag_hours = l.hours
    foreach var in hours lag_hours age {
        egen m_`var' = mean(`var') , by(idcode)
    }
    
    eststo fe: xtreg ln_w hours age i.year, fe
    eststo re: xtreg ln_w hours lag_hours age m_hours m_lag_hours m_age i.year , re
    testparm m_*

    Comment


    • #3
      William:
      welcome to this forum.
      Two asides to George's hepful reply:
      1) the -xi: prefix is redundant with -xtreg-;
      2) if you impose non-default stabdard errors, you have to switch from -hausman- to the community-contributed module -xtoverid-. Being a bit aged, -xtoverid- does not support -fvvarlist- notation and -xi:- is necessary.
      Kind regards,
      Carlo
      (StataNow 18.5)

      Comment

      Working...
      X