Dear Statalisters,

I am analyzing a panel dataset with year dummies over a period of 2000-2018 and
apparently like many other Stata beginners, I came across the issue of (V_b-V_B is not positive definite) when using Hausman test to determine whether to use the FE or RE model.

I tried to follow suggestions of using xtoverid and after installing the package, I encountered the following issue:

Code:
. xtoverid
2b:  operator invalid
r(198);
Please find below my Hausman test and error message for xtoverid.

Notes: I already tried
Code:
hausman fe re, sigmamore
hausman fe re, sigmaless
but the "(V_b-V_B is not positive definite)" was not solved.

Code:
 ** Redo HAUSMAN test to check for RE or FE model

. xtreg wROAf1 IV_CSPaggr geoentropy4rg indentropy CF_age CF_size_lnEmp CF_Levg CF_NPM CF_orgslack CC_WGI s_poptotal CC_WDI
> _PopGrowth s_GDP s_GDPpc CC_WDI_GDPPCgrowth s_fdi CC_WDI_ttUnemplRate i.yeardummy, fe
note: 17.yeardummy omitted because of collinearity

Fixed-effects (within) regression               Number of obs     =     18,964
Group variable: compid                          Number of groups  =      3,780

R-sq:                                           Obs per group:
     within  = 0.0346                                         min =          1
     between = 0.0089                                         avg =        5.0
     overall = 0.0011                                         max =         16

                                                F(30,15154)       =      18.13
corr(u_i, Xb)  = -0.6065                        Prob > F          =     0.0000

-------------------------------------------------------------------------------------
             wROAf1 |      Coef.   Std. Err.      t    P>|t|     [95% Conf. Interval]
--------------------+----------------------------------------------------------------
         IV_CSPaggr |  -.0227671   .0064973    -3.50   0.000    -.0355027   -.0100316
      geoentropy4rg |  -.6074356   .4636818    -1.31   0.190    -1.516308    .3014366
         indentropy |  -.0358456   .2862778    -0.13   0.900    -.5969847    .5252934
             CF_age |   .1352476   .0487664     2.77   0.006     .0396596    .2308355
      CF_size_lnEmp |  -1.551527   .1776825    -8.73   0.000    -1.899806   -1.203248
            CF_Levg |  -3.375775   .6100142    -5.53   0.000    -4.571477   -2.180074
             CF_NPM |   .0023169   .0010765     2.15   0.031     .0002068    .0044269
        CF_orgslack |  -.0353077   .0529923    -0.67   0.505     -.139179    .0685636
             CC_WGI |   2.715108    1.34704     2.02   0.044     .0747483    5.355469
         s_poptotal |  -.0184933   .0304806    -0.61   0.544     -.078239    .0412524
   CC_WDI_PopGrowth |   .1152938   .3522301     0.33   0.743    -.5751196    .8057072
              s_GDP |    .632364   .1654363     3.82   0.000     .3080889    .9566391
            s_GDPpc |  -1.391459   .2382413    -5.84   0.000     -1.85844   -.9244769
 CC_WDI_GDPPCgrowth |   .1399394   .0499854     2.80   0.005      .041962    .2379168
              s_fdi |   .0759093   .0944164     0.80   0.421    -.1091582    .2609769
CC_WDI_ttUnemplRate |   .0317622   .0728713     0.44   0.663    -.1110744    .1745988
                    |
          yeardummy |
              2003  |   1.718398    .660478     2.60   0.009     .4237814    3.013015
              2004  |   2.647522   .5736919     4.61   0.000     1.523017    3.772027
              2005  |   3.015123   .5307992     5.68   0.000     1.974692    4.055553
              2006  |   2.572717   .4936521     5.21   0.000     1.605099    3.540335
              2007  |   .1135621   .4749622     0.24   0.811    -.8174212    1.044545
              2008  |  -.1597079   .4313103    -0.37   0.711    -1.005128    .6857123
              2009  |   2.637556   .4797226     5.50   0.000     1.697242     3.57787
              2010  |    1.65895   .3939397     4.21   0.000     .8867807    2.431119
              2011  |   1.438345   .3699788     3.89   0.000     .7131416    2.163548
              2012  |     .55647   .3401479     1.64   0.102    -.1102609    1.223201
              2013  |   .4664979   .3052461     1.53   0.126    -.1318213    1.064817
              2014  |  -1.235379   .2731461    -4.52   0.000    -1.770778   -.6999793
              2015  |  -.5328104   .2561052    -2.08   0.038    -1.034807   -.0308134
              2016  |   .5114611   .2398972     2.13   0.033     .0412337    .9816885
              2017  |          0  (omitted)
                    |
              _cons |   15.21448   5.054748     3.01   0.003     5.306568     25.1224
--------------------+----------------------------------------------------------------
            sigma_u |  13.647115
            sigma_e |  7.0821539
                rho |  .78783095   (fraction of variance due to u_i)
-------------------------------------------------------------------------------------
F test that all u_i=0: F(3779, 15154) = 6.53                 Prob > F = 0.0000

. estimate store fe

. xtreg wROAf1 IV_CSPaggr geoentropy4rg indentropy CF_age CF_size_lnEmp CF_Levg CF_NPM CF_orgslack CC_WGI s_poptotal CC_WDI
> _PopGrowth s_GDP s_GDPpc CC_WDI_GDPPCgrowth s_fdi CC_WDI_ttUnemplRate i.yeardummy, re

Random-effects GLS regression                   Number of obs     =     18,964
Group variable: compid                          Number of groups  =      3,780

R-sq:                                           Obs per group:
     within  = 0.0190                                         min =          1
     between = 0.0983                                         avg =        5.0
     overall = 0.0484                                         max =         16

                                                Wald chi2(31)     =     642.04
corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000

-------------------------------------------------------------------------------------
             wROAf1 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
--------------------+----------------------------------------------------------------
         IV_CSPaggr |  -.0104024   .0050298    -2.07   0.039    -.0202607   -.0005442
      geoentropy4rg |   .5555316    .326717     1.70   0.089    -.0848219    1.195885
         indentropy |    .040395   .2456707     0.16   0.869    -.4411107    .5219008
             CF_age |   .0183981   .0053646     3.43   0.001     .0078837    .0289125
      CF_size_lnEmp |   .6894453    .093907     7.34   0.000      .505391    .8734995
            CF_Levg |  -3.212073   .5162737    -6.22   0.000     -4.22395   -2.200195
             CF_NPM |   .0021792   .0004408     4.94   0.000     .0013153    .0030432
        CF_orgslack |  -.1645398   .0435363    -3.78   0.000    -.2498694   -.0792102
             CC_WGI |  -.5799745   .4522981    -1.28   0.200    -1.466462    .3065135
         s_poptotal |  -.0020881   .0010709    -1.95   0.051    -.0041871    .0000108
   CC_WDI_PopGrowth |   .1173416   .2527258     0.46   0.642    -.3779918     .612675
              s_GDP |    .013877   .0326286     0.43   0.671    -.0500738    .0778278
            s_GDPpc |  -.4957057   .1248403    -3.97   0.000    -.7403882   -.2510232
 CC_WDI_GDPPCgrowth |   .1474068   .0474048     3.11   0.002      .054495    .2403185
              s_fdi |   .1062363   .0854276     1.24   0.214    -.0611988    .2736714
CC_WDI_ttUnemplRate |   .0051797   .0428637     0.12   0.904    -.0788316     .089191
                    |
          yeardummy |
              2003  |   1.641583   .6825769     2.40   0.016     .3037567    2.979409
              2004  |   2.930763   .6200142     4.73   0.000     1.715558    4.145969
              2005  |   3.252471   .6017448     5.41   0.000     2.073073    4.431869
              2006  |   2.934455   .5998017     4.89   0.000     1.758865    4.110044
              2007  |   .3813269   .6038372     0.63   0.528    -.8021723    1.564826
              2008  |    .252396   .5885435     0.43   0.668    -.9011281     1.40592
              2009  |   3.200676   .6210972     5.15   0.000     1.983348    4.418004
              2010  |   2.266513   .5860811     3.87   0.000     1.117815    3.415211
              2011  |   1.933953   .5919703     3.27   0.001     .7737126    3.094193
              2012  |   1.211612   .5868921     2.06   0.039     .0613248    2.361899
              2013  |    1.19128   .5855447     2.03   0.042     .0436333    2.338926
              2014  |  -.3239355   .5834149    -0.56   0.579    -1.467408    .8195367
              2015  |   .6538636   .5763879     1.13   0.257    -.4758358    1.783563
              2016  |   1.603099   .5801637     2.76   0.006     .4659991    2.740199
              2017  |   1.087371   .5918516     1.84   0.066     -.072637    2.247379
                    |
              _cons |  -.2501154   1.308373    -0.19   0.848     -2.81448    2.314249
--------------------+----------------------------------------------------------------
            sigma_u |   9.609396
            sigma_e |  7.0821539
                rho |  .64801529   (fraction of variance due to u_i)
-------------------------------------------------------------------------------------

. estimate store re

. xttest0

Breusch and Pagan Lagrangian multiplier test for random effects

        wROAf1[compid,t] = Xb + u[compid] + e[compid,t]

        Estimated results:
                         |       Var     sd = sqrt(Var)
                ---------+-----------------------------
                  wROAf1 |   112.5129       10.60721
                       e |    50.1569       7.082154
                       u |   92.34049       9.609396

        Test:   Var(u) = 0
                             chibar2(01) =  6033.36
                          Prob > chibar2 =   0.0000

. xtoverid
2b:  operator invalid
r(198);
Furthermore, I tried to follow suggestions of using Mundlak device in earlier discussions but failed to conduct the Hausman test with the Mundlak test because all newly generated mean(var) were omitted due to collinearity.

Code:
 ** Mundlak approach
egen CSPmean = mean(IV_CSPaggr)
egen Geoentmean = mean(geoentropy4rg)
egen Indentmean = mean(indentropy)
egen agemean = mean(CF_age)
egen sizemean = mean(CF_size_lnEmp)
egen levgmean = mean(CF_Levg)
egen npmmean = mean(CF_NPM)
egen orgslackmean = mean(CF_orgslack)
egen WGImean = mean(CC_WGI)
egen poptotalmean = mean(s_poptotal)
egen popgrowthmean = mean(CC_WDI_PopGrowth)
egen gdpmean = mean(s_GDP)
egen gdppcmean = mean(s_GDPpc)
egen gdppcgrowthmean = mean(CC_WDI_GDPPCgrowth)
egen fdimean = mean(s_fdi)
egen unemplmean = mean(CC_WDI_ttUnemplRate)

xtreg wROAf1 IV_CSPaggr geoentropy4rg indentropy CF_age CF_size_lnEmp CF_Levg CF_NPM CF_orgslack CC_WGI s_poptotal CC_WDI_PopGrowth s_GDP s_GDPpc CC_WDI_GDPPCgrowth s_fdi CC_WDI_ttUnemplRate CSPmean Geoentmean Indentmean agemean sizemean levgmean npmmean orgslackmean WGImean poptotalmean popgrowthmean gdpmean gdppcmean gdppcgrowthmean fdimean unemplmean i.yeardummy, re vce(robust)
note: CSPmean omitted because of collinearity
note: Geoentmean omitted because of collinearity
note: Indentmean omitted because of collinearity
note: agemean omitted because of collinearity
note: sizemean omitted because of collinearity
note: levgmean omitted because of collinearity
note: npmmean omitted because of collinearity
note: orgslackmean omitted because of collinearity
note: WGImean omitted because of collinearity
note: poptotalmean omitted because of collinearity
note: popgrowthmean omitted because of collinearity
note: gdpmean omitted because of collinearity
note: gdppcmean omitted because of collinearity
note: gdppcgrowthmean omitted because of collinearity
note: fdimean omitted because of collinearity
note: unemplmean omitted because of collinearity

Random-effects GLS regression                   Number of obs     =     18,964
Group variable: compid                          Number of groups  =      3,780

R-sq:                                           Obs per group:
     within  = 0.0190                                         min =          1
     between = 0.0983                                         avg =        5.0
     overall = 0.0484                                         max =         16

                                                Wald chi2(31)     =     403.84
corr(u_i, X)   = 0 (assumed)                    Prob > chi2       =     0.0000

                                    (Std. Err. adjusted for 3,780 clusters in compid)
-------------------------------------------------------------------------------------
                    |               Robust
             wROAf1 |      Coef.   Std. Err.      z    P>|z|     [95% Conf. Interval]
--------------------+----------------------------------------------------------------
         IV_CSPaggr |  -.0104024    .005792    -1.80   0.072    -.0217545    .0009497
      geoentropy4rg |   .5555316   .4246757     1.31   0.191    -.2768174    1.387881
         indentropy |    .040395   .2513858     0.16   0.872     -.452312    .5331021
             CF_age |   .0183981   .0037449     4.91   0.000     .0110582     .025738
      CF_size_lnEmp |   .6894453   .1634117     4.22   0.000     .3691641    1.009726
            CF_Levg |  -3.212073   1.113767    -2.88   0.004    -5.395016   -1.029129
             CF_NPM |   .0021792   .0011534     1.89   0.059    -.0000814    .0044399
        CF_orgslack |  -.1645398   .0894728    -1.84   0.066    -.3399033    .0108237
             CC_WGI |  -.5799745   .4286284    -1.35   0.176    -1.420071    .2601217
         s_poptotal |  -.0020881   .0008452    -2.47   0.013    -.0037447   -.0004315
   CC_WDI_PopGrowth |   .1173416   .2156586     0.54   0.586    -.3053415    .5400247
              s_GDP |    .013877   .0344897     0.40   0.687    -.0537215    .0814755
            s_GDPpc |  -.4957057   .1313103    -3.78   0.000    -.7530691   -.2383423
 CC_WDI_GDPPCgrowth |   .1474068   .0596172     2.47   0.013     .0305592    .2642544
              s_fdi |   .1062363   .0843957     1.26   0.208    -.0591762    .2716489
CC_WDI_ttUnemplRate |   .0051797   .0422669     0.12   0.902     -.077662    .0880214
            CSPmean |          0  (omitted)
         Geoentmean |          0  (omitted)
         Indentmean |          0  (omitted)
            agemean |          0  (omitted)
           sizemean |          0  (omitted)
           levgmean |          0  (omitted)
            npmmean |          0  (omitted)
       orgslackmean |          0  (omitted)
            WGImean |          0  (omitted)
       poptotalmean |          0  (omitted)
      popgrowthmean |          0  (omitted)
            gdpmean |          0  (omitted)
          gdppcmean |          0  (omitted)
    gdppcgrowthmean |          0  (omitted)
            fdimean |          0  (omitted)
         unemplmean |          0  (omitted)
                    |
          yeardummy |
              2003  |   1.641583   .4706248     3.49   0.000     .7191752     2.56399
              2004  |   2.930763    .580364     5.05   0.000     1.793271    4.068256
              2005  |   3.252471   .5911194     5.50   0.000     2.093898    4.411043
              2006  |   2.934455   .6290839     4.66   0.000     1.701473    4.167436
              2007  |   .3813269   .6928329     0.55   0.582    -.9766007    1.739254
              2008  |    .252396   .5860639     0.43   0.667     -.896268     1.40106
              2009  |   3.200676   .6079538     5.26   0.000     2.009109    4.392244
              2010  |   2.266513   .6160047     3.68   0.000     1.059166     3.47386
              2011  |   1.933953   .6155617     3.14   0.002     .7274743    3.140432
              2012  |   1.211612   .5967539     2.03   0.042      .041996    2.381228
              2013  |    1.19128   .5951258     2.00   0.045     .0248547    2.357705
              2014  |  -.3239355    .605627    -0.53   0.593    -1.510943    .8630717
              2015  |   .6538636   .5871039     1.11   0.265    -.4968388    1.804566
              2016  |   1.603099    .580165     2.76   0.006     .4659965    2.740202
              2017  |   1.087371   .6118433     1.78   0.076      -.11182    2.286562
                    |
              _cons |  -.2501154   1.708782    -0.15   0.884    -3.599267    3.099036
--------------------+----------------------------------------------------------------
            sigma_u |   9.609396
            sigma_e |  7.0821539
                rho |  .64801529   (fraction of variance due to u_i)
-------------------------------------------------------------------------------------
estimates store mundlak


testparm CSPmean Geoentmean Indentmean agemean sizemean levgmean npmmean orgslackmean WGImean poptotalmean popgrowthmean gdpmean gdppcmean gdppcgrowthmean fdimean unemplmean

no such variables;
the specified varlist does not identify any testable coefficients
r(111);
I would highly appreciate your feedback on my mistakes and support in solving them.

Kind regards,

Jennifer