Hello,

I am a complete novice in terms of Stata and have encountered a challenge I can’t seem to overcome. I have tried searching the forum (and web) for answers but haven’t found one that lets me overcome the challenge.

I have a two-way fixed effects model with two-way clustering using reghdfe on panel data with T = 10 and N = 423. To test the use of FE I would like to run a Hausman test. However, I can't seem to figure out how to run a Hausman test with two-way clustering, nor am I sure how to run a equivalent model with RE since I am using reghdfe.

Code:
. reghdfe BVLEV_1 L.INNO L.SIZE L.AGE L.TANG L.PROF L.GRTH L.NDTS L.MrktD c.L.INNO#i.L.MrktD, absorb(Year FIRM) vce(cluster Year FIRM)
Code:
* Example generated by -dataex-. For more info, type help dataex
clear
input float(BVLEV_1 INNO) double(SIZE AGE) float(TANG PROF GRTH NDTS MrktD)
        .         0 25.140104442084407  4.736198448394496   .2805809   .1225458  1.728044          0 1
1.0106446         0 25.271209371482893   4.74493212836325  .26030242    .102776 1.0134124          0 1
 .9059817  .6931472  25.31613062108747 4.7535901911063645  .24522354  .12964672 1.2477313          0 1
1.0244187         0 25.199010475505425  4.762173934797756   .2690079  .09200912  1.211202          0 1
 .9241343         0 25.212149367154357  4.770684624465665  .25968078  .09518524  .9013919          0 1
 .9028375         0 25.177729405521426   4.77912349311153   .2600798  .07181802  .9193362          0 1
 .8666971         0  25.12733523500807  4.787491742782046  .25805798   .1064541 1.3683108          0 1
 .7276743         0 25.279035672649883  4.795790545596741   .2284465   .1694506 1.6841967          0 1
 .6681173         0 25.342871330740614  4.804021044733257  .21429476  .15791163 1.3381064          0 1
 .3958571         0 25.371792403193993  4.812184355372417  .23927324  .11115817  1.897365          0 1
        .         0 25.533537795756093  4.736198448394496  .07599856  .07023368  .7052656          0 1
1.1333276         0  25.54093107974409   4.74493212836325  .08478917   .1016431 .56339264          0 1
1.2531534         0  25.59322043341546 4.7535901911063645   .0899643  .04553749  .4952209          0 1
1.2157818         0 25.646176772676757  4.762173934797756  .08490727  .06337555  .6159959          0 1
1.2367824         0  25.69303746899461  4.770684624465665   .0767672  .05830297  .7429931          0 1
1.2092685         0 25.762287725487898   4.77912349311153  .06659363  .06440251  .6952531          0 1
1.0835882         0 25.717032993922302  4.787491742782046  .06419417  .06779025   .830492          0 1
1.2075226         0  25.79551036601393  4.795790545596741 .062812395  .04183229  .6352618          0 1
 1.202427         0  25.87415570568361  4.804021044733257  .06573743  .04855713  .4949357          0 1
1.1884935         0 25.879080258005892  4.812184355372417  .10492945  .05894396  .6899122          0 1
        .  5.755742 24.196535787431234  4.736198448394496  .14523625  .08608548 1.1286103          0 1
 .6924891  6.234411 24.136589398439337   4.74493212836325  .13476273  .05329347  .6220146          0 1
 .7580355  5.958425 24.152208078949545 4.7535901911063645   .1254282  .05762918  .8005841          0 1
 .7836558  5.720312  24.13471053509311  4.762173934797756  .13485539   .0600852  .8276075          0 1
 .7642021  6.570883 24.215400213631103  4.770684624465665  .15209243  .05421892 1.1268517          0 1
 .7537746  6.526495   24.3121315669416   4.77912349311153   .1557181  .09528464 1.0803771          0 1
 .7622334  6.122493 24.306479173183142  4.787491742782046   .1659288   .0975802 1.2334186          0 1
 .7618092  6.113682  24.39860402051902  4.795790545596741  .16392794  .10700773 1.2668626          0 1
 .8007717  5.940171 24.440441160239498  4.804021044733257   .1601782  .05361722  .9788643          0 1
 .8087863  4.867535 24.472299213903636  4.812184355372417          0   .0878969 1.0270094          0 1
        .         0  21.31712734644807 4.7535901911063645   .6161835 .035405505  .4728191   .0820877 0
 .4618512         0 21.337435284753997  4.762173934797756  .55176055  .04723222 .56485796  .07206534 0
 .5941403         0  21.36078455087655  4.770684624465665   .6694127  .05526852  .5964243     .04811 0
 .6679801         0   21.4577257720642   4.77912349311153     .60712  .08645748  .5824009  .04505779 0
        .         0 23.695985336242494  4.736198448394496   .7190117  .04887533   .553095  .03741924 1
 .7705187         0  23.86249221018245   4.74493212836325   .7456001  .14748636  .4454397 .033855498 1
  .682672  1.609438  23.65903576938081 4.7535901911063645   .3385791  .04103007 .43538275 .035442423 1
 .6286231  2.484907 23.587521747769042  4.762173934797756   .3293337 .029031644  .5320368  .03727587 1
.59591955  2.564949 23.578585956841195  4.770684624465665   .3091892  .03524181  .6112404 .034720317 1
.57921785         0  23.57379891306601   4.77912349311153   .2910932 .021688854  .6228262  .05062613 1
 .5702116 1.0986123  23.59059639575273  4.787491742782046  .26903787  .05534378  .7834185  .02917658 1
 .5314447   1.94591  23.58866160882936  4.795790545596741   .2601817          0 1.0465562  .02840274 1
 .5513356  .6931472 23.624852252665107  4.804021044733257   .2459092  .06453186  .7979235  .02741656 1
 .4822459         0 24.043795315577245  4.812184355372417   .8499157   .1873104  .7865514  .02106505 1
        .         0  22.28098931390445  4.770684624465665   .3840807  .09461883  .8451321  .04506727 1
 .6773132         0  22.42692242480151   4.77912349311153   .3791458  .12221717 1.1784273  .04725125 1
 .9319066 3.2580965 22.698318613027467  4.787491742782046   .4210063  .07018868  .8177284 .033333335 1
 .8060787  2.772589 23.159944664508608  4.795790545596741   .3842118   .1145391  .7923383  .04621534 1
 .8309887 1.3862944  23.28126804188242  4.804021044733257   .4161632  .10714693  .6933689  .04023709 1
  .908798  .6931472 23.206337470872167  4.812184355372417  .48673666    .079771  .7126593  .04398855 1
        .         0 24.037888110112725  4.663439094112067  .20535256  .07454053  .7056163          0 1
   .78619         0 24.107147496432795  4.672828834461906  .20766094   .0847304  .5626268          0 1
  .759084         0   23.7972083710832   4.68213122712422   .1808103   .0906814  .8042296          0 1
 .6937635         0  23.81739443240191 4.6913478822291435  .18839782  .09374084 1.2695315          0 1
 .7142321         0   23.8684520637118  4.700480365792417  .18411104  .09293253 1.0812703          0 1
 .7059544         0 23.980323373893167  4.709530201312334   .1874382   .1009305  1.300577          0 1
 .7414396         0 24.046249393101697  4.718498871295094  .19512346 .064213924 1.0034713          0 1
 .6974292         0 24.196225584866482  4.727387818712341  .19427302  .08273678 1.0555807          0 1
 .6635369         0 24.272739535271963  4.736198448394496  .20506677  .08730604  .7278484          0 1
 .7489944         0 24.335264246751386   4.74493212836325  .23616904   .0170746  .8092557          0 1
        .  6.767343  24.84321316656426 4.6443908991413725  .23399247   .1530494 1.5778688          0 1
 .6145601  6.999423 24.929092141846183  4.653960350157523  .22023107  .16188905 1.1156516          0 1
 .8525485   7.23201 24.901093336322354  4.663439094112067   .2153826  .12069391 1.2227247          0 1
 .6608409  7.525101 24.884739312357365  4.672828834461906   .1985463  .05202068 1.0817511          0 1
 .6709611  7.751045  24.99147966916149   4.68213122712422  .18963976  .09555482  .9194262          0 1
 .6702911  7.624131 25.054709451257363 4.6913478822291435  .19192806  .08739167  .7840677          0 1
  .656939  6.656726  25.01080320478844  4.700480365792417  .18766014  .08970646  .9115818          0 1
 .8626414  6.364751  25.07917947577587  4.709530201312334  .19410613   .1058089 1.0186787          0 1
 .6024605  5.986452  25.19152750567851  4.718498871295094  .19143543  .12674797  .7005265          0 1
 .8392656  5.631212  25.18092160765754  4.727387818712341   .2275152   .0998321  .9155501          0 1
        .         0 21.286085060398946  4.634728988229636  .18472242 -.03785776 .26592264          0 1
  .799298         0 21.361346297431304 4.6443908991413725   .1597743  .05477314  .1627046          0 1
 .8547568         0 21.417737140967827  4.653960350157523   .1535219  .05243392   .216123          0 1
 .8669059         0 21.487178517425455  4.663439094112067   .1421967  .05316325  .2241691          0 1
 .9250264         0  22.04845471091829  4.672828834461906  .10988519  .04891023  .2852529          0 1
 .8776872         0  22.17889431155691   4.68213122712422  .09379284  .08198924  .5102885          0 1
 .9845775         0 22.577186002682694 4.6913478822291435    .118811    .050721 .55521816          0 1
1.0301828         0 22.966175232858753  4.700480365792417  .11179797  .04159862  .3913315          0 1
 .9712481         0  23.10771659050218  4.709530201312334  .10200204   .0592987  .3879843          0 1
1.0335312         0  23.14959836545931  4.718498871295094 .067471266  .03896626   .333397          0 1
        .  4.875197 25.389907345032007   4.61512051684126  .19899076  .07385645  .7468041          0 1
 .8884309  4.990433 25.346550952369494  4.624972813284271    .244148   .0394978  .4098155          0 1
1.0635477  5.257495 25.424400534081013  4.634728988229636   .2192063  .05449627   .640307          0 1
1.1581262  5.521461  25.41631868691919 4.6443908991413725   .2271549   .0207892  .6342526          0 1
 .9200982  5.416101  25.44460887405928  4.653960350157523  .22096443  .04179115  .7652075          0 1
 .9452122 4.4426513 25.540138372607856  4.663439094112067  .22103485 .032837752  .7096379          0 1
 .9826649 4.4998097 25.521623333047007  4.672828834461906  .21811807 .073082656  .7592581          0 1
   .94481 4.1743875 25.530462163010963   4.68213122712422  .21400774  .08259459  .8449045          0 1
 .9603899  2.833213 25.546004059923572 4.6913478822291435  .21670502  .05456676  .5521333          0 1
1.0113537 2.0794415  25.51107419627515  4.700480365792417   .2304509 .029857313  .6177271          0 1
        .  .6931472  26.30204804427632  4.564348191467836  .23235023  .05660253  .7365565          0 1
1.0989978         0 26.461021305173926  4.574710978503383  .22211842   .0761485  .4265231          0 1
1.0847838         0 26.439131679448664  4.584967478670572   .2480531   .0520219  .5241512          0 1
1.1244308         0  26.33223200982412   4.59511985013459  .22592357 .020700116  .4890538          0 1
 1.299305         0 26.368868199539683  4.605170185988092  .22564612 .015210397  .4428461          0 1
1.0879376         0 26.482558701533332   4.61512051684126  .23024334          0 .42624265          0 1
1.0736886         0 26.434295321811224  4.624972813284271  .22703527  .05220648 .53496367          0 1
1.0511376 2.0794415 26.541242693517702  4.634728988229636  .21943107  .07352107  .7395294          0 1
1.1086005         0  26.69660714579725 4.6443908991413725   .2080971   .0726368  .4884022          0 1
1.0815631         0  26.79659604452628  4.653960350157523  .18448013  .09437406  .6085445          0 1
end