Announcement

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

  • Hausman and testparm

    Hello everyone,
    Just a little confused, I currently have a panel data and I am choosing between using random effects or fixed effects. When I run my regression first without an i.Year variable I find through a Hausman test that FE is more suited for this regression. However I then use testparm in order to see if I need to include a i.Year variable and the result of Prob is less than 0.05 which indicates I should. Once I include the i.year variable in my regression the value of the Hausman test changes completely and goes to 0.9457 from 0.0013 (which was the value of the Hausman test before including the i.Year variable). This new Hausman would indicate that a random effects regression might be more suited. However my questions are;
    1. Why does the value of the Hausman change so much?
    2. Is it more logical to do the Hausman test including the i.Year variable or without it?

    Many thanks
    Pepito

  • #2
    I will not advance a long reply because I believe that an exchange in an online forum should not be a substitute for learning the theory behind what you are doing. You do not provide the syntax, but what I suppose you are testing for is the difference between a two-way fixed effects model and a one-way random effects model with year dummies (not to be mistaken with a two-way random effects model). In the fixed effects context, the year dummies are just nuisance parameters, i.e., of no immediate interest but which must be accounted for in the analysis of those parameters which are of interest (that being your time-varying regressors). In addition, the coefficients that you obtain will depend on what base category you specify (or Stata selects for you). Therefore, they should not be part of the Hausman test. While it is possible to run a Hausman test to choose between a two-way fixed effects model and a one-way random effects model, you will want to compare like for like. To this end, a comparison between a two-way fixed effects model and a two-way random effects model cannot be done using xtreg as you cannot include more than one random effect using this command. You will therefore need to switch to mixed.

    Comment


    • #3
      Hello Andrew,
      Many thanks for your help, I am still a bit confused by what you said, this is the following code that I meant:
      So do I do the Hausman test without a i.yeear variable as:
      xtreg gincdif11 immigrants lnNative lnRGDP agea lnage dummy_educ hincfel,fe
      estimates store fixed
      ** Now we run a Random Effects**
      xtreg gincdif11 immigrants lnNative lnRGDP agea lnage dummy_educ hincfel,re
      estimates store random
      ** Running a Hausman test **
      hausman fixed random

      or as:
      xtreg gincdif11 immigrants lnNative lnRGDP agea lnage dummy_educ hincfel i.year,fe
      estimates store fixed
      ** Now we run a Random Effects**
      xtreg gincdif11 immigrants lnNative lnRGDP agea lnage dummy_educ hincfel i.year,re
      estimates store random
      ** Running a Hausman test **
      hausman fixed random

      Comment


      • #4
        xtreg gincdif11 immigrants lnNative lnRGDP agea lnage dummy_educ hincfel,re
        estimates store random
        ** Running a Hausman test **
        hausman fixed random
        This is valid.

        xtreg gincdif11 immigrants lnNative lnRGDP agea lnage dummy_educ hincfel i.year,fe
        estimates store fixed
        ** Now we run a Random Effects**
        xtreg gincdif11 immigrants lnNative lnRGDP agea lnage dummy_educ hincfel i.year,re
        estimates store random
        ** Running a Hausman test **
        hausman fixed random
        This is not valid as the i.year coefficients enter into the Hausman test.

        Comment


        • #5
          Pepito:
          you do not say whether your model without -i.year. is misspecified or not: it may be that -i.year- makes the difference in this respect, and favours -re- specification.
          In the following toy-example, the regression odel is clearly misspecified, as -test- run on squared fitted values reaches statistical significance:
          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, fe
          
          Fixed-effects (within) 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
          
                                                          F(1,23799)        =    2720.20
          corr(u_i, Xb)  = 0.0314                         Prob > F          =     0.0000
          
          ------------------------------------------------------------------------------
               ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                   age |   .0181349   .0003477    52.16   0.000     .0174534    .0188164
                 _cons |   1.148214   .0102579   111.93   0.000     1.128107     1.16832
          -------------+----------------------------------------------------------------
               sigma_u |  .40635023
               sigma_e |  .30349389
                   rho |  .64192015   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          F test that all u_i=0: F(4709, 23799) = 8.81                 Prob > F = 0.0000
          
          
          . predict u, xb
          (24 missing values generated)
          
          . g sq_u=u^2
          (24 missing values generated)
          
          . xtreg ln_wage u sq_u, fe
          
          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,23798)        =    1451.88
          corr(u_i, Xb)  = 0.0440                         Prob > F          =     0.0000
          
          ------------------------------------------------------------------------------
               ln_wage |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                     u |   7.143466    .478902    14.92   0.000     6.204788    8.082144
                  sq_u |  -1.816243    .141469   -12.84   0.000    -2.093531   -1.538955
                 _cons |  -5.167788   .4037984   -12.80   0.000    -5.959259   -4.376317
          -------------+----------------------------------------------------------------
               sigma_u |   .4039153
               sigma_e |  .30245467
                   rho |  .64073314   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          F test that all u_i=0: F(4709, 23798) = 8.74                 Prob > F = 0.0000
          
          . test sq_u
          
           ( 1)  sq_u = 0
          
                 F(  1, 23798) =  164.83
                      Prob > F =    0.0000
          
          .
          Kind regards,
          Carlo
          (Stata 19.0)

          Comment


          • #6
            Thank you Andrew,
            And Carlo, thank you as well for your contribution, I run such test and get Prob>F= 0.0938.
            I suppose in this case the test run does not reach statistical significance and hence my model is not specified and I can proceed with the Hausman test as stated by Andrew?
            Thanks

            Comment


            • #7
              These are the results
              ------------------------------------------------------------------------------
              gincdif11 | Coef. Std. Err. t P>|t| [95% Conf. Interval]
              -------------+----------------------------------------------------------------
              u | 1.357232 .2585603 5.25 0.000 .8376358 1.876829
              sq_u | -.1135971 .0664771 -1.71 0.094 -.2471879 .0199937
              _cons | -.1540735 .2984242 -0.52 0.608 -.7537795 .4456324
              -------------+----------------------------------------------------------------
              sigma_u | .97955953
              sigma_e | .13547629
              rho | .98123121 (fraction of variance due to u_i)
              ------------------------------------------------------------------------------
              F test that all u_i=0: F(16, 49) = 4.44 Prob > F = 0.0000

              . test sq_u

              ( 1) sq_u = 0

              F( 1, 49) = 2.92
              Prob > F = 0.0938



              .
              end of do-file

              Comment


              • #8
                Pepito:
                there's no evidence that your model is misspecified.
                However, I cannot get from your post which one of the two models your test refers to.
                Kind regards,
                Carlo
                (Stata 19.0)

                Comment


                • #9
                  Thanks Carlo, and this is testing the fixed effect model without the i.Year variable.

                  Comment


                  • #10
                    Pepito:
                    then compare -fe- vs -re- specification via -hausman- (without -i.year-) and act on its outcome.
                    Kind regards,
                    Carlo
                    (Stata 19.0)

                    Comment


                    • #11
                      Ok perfect! Thanks so much for your help

                      Comment

                      Working...
                      X