Announcement

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

  • 'xtoverid' after multiple imputation in panel data?

    Hello there, I am a first time Stata user and am having a few problems. I already searched in this forum for a few hours but could not find answers to my problems.

    I am running a panel data analysis on the effects of board diversity on firm performance over the time period from 2007-2017. I also include interaction terms in the analysis. All in all I have 18,354 observations and 1,712 companies.
    Since I have missing values, I decided to do multiple imputation (due to the fact that my dataset is a panel, I reshape and impute in the wide format)

    - reshape wide y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, i(ID) j(year) -
    - mi set wide -
    - mi register imputed x12007 x12008 etc. -
    - mi impute mvn x12007 x12008 etc. -
    - reshape long y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, i(ID) j(year) -

    The multiple imputation works perfectly fine. After that, I test statistical assumptions (testparm _Iyear*; xttest3; kdensity) which indicate that I have to control for autocorrelation, heteroskedasticity and non-normal distribution. As far as I understand, the -xtreg vce(cluster ID)- function is perfect to use in my case.
    To test whether to use fixed or random effects, I considered doing the Hausman test, but I cannot use the hausman test with robust standard errors. Thus I want to try the xtoverid command which is written by stata users. Gievn the fact that I did a multiple imputation before, I always put mi estimate before the actual analysis:
    Code:
    mi estimate: xtreg y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, fe vce(cluster ID)
    estimates store FE
    mi estimate: xtreg y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, re vce(cluster ID)
    estimates store RE
    xtoverid
    However, when I use it, it just says: xtoverid works only after xtreg, xtivreg, xtivreg2 or xthtaylor; last estimates not found

    I also tried the xtoverid command without multiple imputation (i.e. I ran the regression without multiple imputation which reduces my observations)
    Code:
    xtreg y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, fe vce(cluster ID)
    estimates store FE
    xtreg y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, re vce(cluster ID)
    estimates store RE
    xtoverid
    In that case, the xtoverid command works fine and says that I should use fixed effects.

    Now what should I do?
    I know that the hausman test has to be slightly adapted after multiple imputation
    Code:
    mi estimate, post: xtreg y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, fe
    estimates store FE
    mi estimate, post: xtreg y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, re
    hausman FE
    but I didn't find anything similar for the xtoverid command. Does anyone know how to handle the situation?

    I would appreciate your help a lot! Thanks in advance!
    Last edited by Katharina Hofmann; 29 May 2019, 11:04.

  • #2
    You can always use the post option to access the (final) MI estimates. How these are representative of all estimates, I do not know... a lot of post estimation commands in Stata have not been adapted to take into account multiple imputation.

    Code:
    mi estimate, post: xtreg y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, fe vce(cluster ID)
    estimates store FE
    mi estimate, post: xtreg y x1 x2 x3 x4 x1*x2 x1*x3 x1*x4, re vce(cluster ID)
    estimates store RE
    xtoverid
    I know that I have previously suggested this for the Hausman test, but I should have included the above qualification. In any case, if the missing values are sufficiently small, I doubt that it affects the general results of these tests.

    Comment


    • #3
      I have also tried the command with the post option, but then it just says 'no observations'..

      Comment


      • #4
        You are right, for some reason, the coefficients are posted but not the variance estimates as the example below shows:

        Code:
        . webuse mjsps5, clear
        (LEA Junior School Project data (Mortimore et al., 1988) with missing values)
        
        . mi xtset school
               panel variable:  school (unbalanced)
        
        . mi estimate, post: xtreg math5 math3, fe
        
        Multiple-imputation estimates                   Imputations       =          5
        Fixed-effects (within) regression               Number of obs     =        887
        
        Group variable: school                          Number of groups  =         48
                                                        Obs per group:
                                                                      min =          5
                                                                      avg =       18.5
                                                                      max =         62
                                                        Average RVI       =     0.0548
                                                        Largest FMI       =     0.0929
                                                        Complete DF       =        838
        DF adjustment:   Small sample                   DF:     min       =     303.32
                                                                avg       =     557.77
                                                                max       =     812.21
        Model F test:       Equal FMI                   F(   1,  303.3)   =     296.17
        Within VCE type: Conventional                   Prob > F          =     0.0000
        
        ------------------------------------------------------------------------------
               math5 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
               math3 |   .6149025     .03573    17.21   0.000     .5445924    .6852127
               _cons |   30.41659   .1797189   169.25   0.000     30.06382    30.76935
        -------------+----------------------------------------------------------------
             sigma_u |  2.4839812
             sigma_e |  5.3206673
                 rho |  .17895077   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        Note: sigma_u and sigma_e are combined in the original metric.
        
        . est store FE
        
        . est replay FE
        
        --------------------------------------------------------------------------------------------------------------------------------------------------
        Model FE
        --------------------------------------------------------------------------------------------------------------------------------------------------
        
        Fixed-effects (within) regression               Number of obs     =        887
        Group variable: school                          Number of groups  =         48
        
        R-sq:                                           Obs per group:
             within  =      .                                         min =          5
             between =      .                                         avg =       18.5
             overall =      .                                         max =         62
        
                                                        F(.,838)          =          .
        corr(u_i, Xb)  =      .                         Prob > F          =          .
        
        ------------------------------------------------------------------------------
               math5 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
        -------------+----------------------------------------------------------------
               math3 |   .6149025     .03573    17.21   0.000     .5445924    .6852127
               _cons |   30.41659   .1797189   169.25   0.000     30.06382    30.76935
        -------------+----------------------------------------------------------------
             sigma_u |          .
             sigma_e |          .
                 rho |          .   (fraction of variance due to u_i)
        ------------------------------------------------------------------------------
        F test that all u_i=0: F(., 838) = .                         Prob > F =      .
        Here is a work-around. Store the coefficients' matrix and variance matrix and then write a small program to post these to e(b) and e(V). You can use the program repeatedly but make sure that you always replace the coefficients' matrix and variance matrix with the correct ones.

        Code:
        *EXAMPLE DATA
        webuse mjsps5, clear
        mi xtset school
        *REGRESSION WITH POST OPTION
        mi estimate, post: xtreg math5 math3, fe cluster(school)
        * STORE MATRICES
        mat b= e(b)
        mat V= e(V)
        *RUN SAME REGRESSION WITHOUT MI ESTIMATE
        xtreg math5 math3, fe cluster(school)
        *PROGRAM TO REPLACE COEFFICIENTS' AND VARIANCE MATRIX
        program repostBV, eclass
        erepost b=b
        erepost V=V
        end
        *RUN PROGRAM
        repostBV
        *SAVE ESTIMATES AND CONFIRM THEY CORRESPOND TO MI RESULTS
        est store FE
        est replay FE
        *DO THE SAME FOR RE MODEL
        mi estimate, post: xtreg math5 math3, re cluster(school)
        * STORE MATRICES
        mat b= e(b)
        mat V= e(V)
        *RUN SAME REGRESSION WITHOUT MI ESTIMATE
        xtreg math5 math3, re cluster(school)
        *RUN PROGRAM
        repostBV
        *SAVE ESTIMATES AND CONFIRM THEY CORRESPOND TO MI RESULTS
        est store RE
        est replay RE
        *FINALLY, RUN XTOVERID
        xtoverid

        Comment


        • #5
          Please disregard my reply in #4, switching the coefficients' matrix and variance matrix will only be valid for the Hausman test which examines differences between coefficients. xtoverid (SSC) performs a test of overidentifying restrictions, and can be implemented by means of an artificial regression. For a comparison between a fixed effects and a random effects model, one can generate mean-deviated variables (for each of the regressors) and augment these to the random effects regression. The test of overidentifying restrictions is the wald test that these mean deviated variables are jointly equal to zero. Here is an example using the Grunfeld dataset.

          Code:
          webuse grunfeld, clear
          xtreg invest mvalue kstock, re cluster(company)
          *RUN XTOVERID COMMAND
          xtoverid
          *GENERATE MEAN DEVIATED REGRESSORS
          foreach var in mvalue kstock{
          bys company: egen m`var'=mean(`var')
          gen md`var'=`var' -m`var'
          }
          *ARTIFICIAL REGRESSION
          xtreg invest mvalue kstock mdmvalue mdkstock, re cluster(company)
          *TEST OF OVERIDENTIFYING RESTRICTIONS
          test mdmvalue mdkstock
          Result:

          Code:
          . xtoverid
          
          Test of overidentifying restrictions: fixed vs random effects
          Cross-section time-series model: xtreg re  robust cluster(company)
          Sargan-Hansen statistic   7.320  Chi-sq(2)    P-value = 0.0257
          
          . *ARTIFICIAL REGRESSION
          
          . xtreg invest mvalue kstock mdmvalue mdkstock, re cluster(company)
          
          Random-effects GLS regression                   Number of obs     =        200
          Group variable: company                         Number of groups  =         10
          
          R-sq:                                           Obs per group:
               within  = 0.7668                                         min =         20
               between = 0.8578                                         avg =       20.0
               overall = 0.8359                                         max =         20
          
                                                          Wald chi2(4)      =     125.84
          corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000
          
                                         (Std. Err. adjusted for 10 clusters in company)
          ------------------------------------------------------------------------------
                       |               Robust
                invest |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
          -------------+----------------------------------------------------------------
                mvalue |   .1346461    .016897     7.97   0.000     .1015286    .1677635
                kstock |   .0320318   .0836383     0.38   0.702    -.1318962    .1959598
              mdmvalue |  -.0245223   .0149885    -1.64   0.102    -.0538991    .0048546
              mdkstock |   .2780335   .1030273     2.70   0.007     .0761037    .4799633
                 _cons |  -8.527168   19.42001    -0.44   0.661    -46.58968    29.53534
          -------------+----------------------------------------------------------------
               sigma_u |  90.234986
               sigma_e |  52.767964
                   rho |  .74517193   (fraction of variance due to u_i)
          ------------------------------------------------------------------------------
          
          . *TEST OF OVERIDENTIFYING RESTRICTIONS
          
          . test mdmvalue mdkstock
          
           ( 1)  mdmvalue = 0
           ( 2)  mdkstock = 0
          
                     chi2(  2) =    7.32
                   Prob > chi2 =    0.0257

          Now, in the case of multiple imputation (MI), given the difficulty in implementing the test post MI, I would suggest that one generates these mean deviated variables pre MI and include them in the imputation. Thereafter, use the artificial regression to perform this test.

          Code:
          *EXAMPLE DATA
          webuse mjsps5, clear
          *GENERATE MEAN DEVIATED REGRESSORS
          foreach var in math3{
          bys school: egen m`var'=mean(`var')
          gen md`var'=`var' -m`var'
          }
          *MI RANDOM EFFECTS REGRESSION
          mi xtset school
          mi estimate: xtreg math5 math3 mdmath3, re cluster(school)
          mi test mdmath3
          *or
          mi estimate, post: xtreg math5 math3 mdmath3, re cluster(school)
          test mdmath3

          Comment

          Working...
          X