Hello! I am having some trouble running the necessary model diagnostics for a fixed effects regression undertaken with reghdfe for a three-dimensional panel dataset (index variables are reporting_econ_id, partner_econ_id and year). I first set up the panel structure of my dataset like this:
The resulting dataset looks like this:
I run several nested models, all of which present a good (<0.001) F-statistic. I am presenting below the last model I run and its output:
However, I am now running into issues trying to run model diagnostics, such as B-P/LM test using xttest2 or Pasaran CD test using xtcsd. For xttest2, I receive the following error: "Error: too few common observations across panel to compute full rank VCE"; while for xtcsd I receive the following "Error: The panel is highly unbalanced. Not enough common observations across panel to perform Pesaran's test. Insufficient observations". I believe these erros might be due to the fact that my panel dataset has panel_id as the cross-section identifier. How can I fix these issues and still run my model diagnostics? Thank you in advance!
Code:
encode reportingecon, gen(reporting_econ_id) encode partnerecon, gen(partner_econ_id) egen panel_id = group(reporting_econ_id partner_econ_id) xtset panel_id year
Code:
Observations: 12,200
Variables: 65 7 Oct 2024 08:40
-----------------------------------------------------------------------------------------
Variable Storage Display Value
name type format label Variable label
-----------------------------------------------------------------------------------------
partnerecon str14 %14s PartnerEcon
reportingecon str37 %37s ReportingEcon
agree float %9.0g
year int %8.0g Year
idealpointdis~e float %9.0g IdealPointDistance
region str27 %27s
buildingprodu~x float %9.0g Building Productive Capacity.x
economicinfra~x float %9.0g Economic Infrastructure.x
tradepolicyre~x float %9.0g Trade Policy & Regulations.x
traderelateda~x float %8.0g Trade-related Adjustment.x
total_aftx float %9.0g Total_AfT.x
col_fr byte %8.0g COL_FR
col_uk byte %8.0g COL_UK
col_us byte %8.0g COL_US
col_jp byte %8.0g COL_JP
dist float %8.0g
distcap float %8.0g
distw float %8.0g
distwces float %8.0g
inflowsofasyl~s double %10.0g Inflows of asylum seekers
inflowsoffore~n long %8.0g Inflows of foreign population
incomegroup int %8.0g IncomeGroup
hdi double %10.0g
le float %9.0g
mys float %8.0g
gni_capita double %10.0g
lldcs byte %8.0g LLDCs
count_interna~d int %8.0g
count_intrast~e int %8.0g
count_interst~e int %8.0g
share_world_m~h float %8.0g Share_World_Merch
civ_liberties byte %8.0g
pol_freedom byte %8.0g
balanced_exp float %8.0g Balanced_EXP
balanced_imp float %8.0g Balanced_IMP
final_exp float %8.0g Final_EXP
final_imp float %8.0g Final_IMP
goodsexports float %8.0g GoodsExports
goodsimports float %8.0g GoodsImports
net_fdi double %8.0g Net_FDI
sum_total_aft float %8.0g
other_aft float %8.0g
net_oda float %8.0g Net_ODA
gdp float %8.0g GDP
natural_resou~s float %8.0g
reporting_eco~d long %37.0g reporting_econ_id
ReportingEcon
partner_econ_id long %14.0g partner_econ_id
PartnerEcon
panel_id float %9.0g group(reporting_econ_id partner_econ_id)
mean_totalaft float %9.0g
ln_aft float %9.0g
ln_gnicap float %9.0g
ln_servicesexp float %9.0g
ln_servicesimp float %9.0g
ln_goodsexp float %9.0g
ln_goodsimp float %9.0g
ln_fdi float %9.0g
ln_gdp float %9.0g
ln_otheraft float %9.0g
ln_oda float %9.0g
ln_dist float %9.0g
partner_us float %9.0g
partner_jp float %9.0g
partner_fr float %9.0g
partner_uk float %9.0g
partner_ge float %9.0g
-----------------------------------------------------------------------------------------
Sorted by: panel_id year
Code:
reghdfe ln_aft ///
c.hdi#i.partner_econ_id ///
c.ln_gnicap#i.partner_econ_id ///
c.pol_freedom#i.partner_econ_id ///
lldcs#i.partner_econ_id ///
c.share_world_merch#i.partner_econ_id ///
c.count_internationalised#i.partner_econ_id ///
c.count_intrastate#i.partner_econ_id ///
c.agree#i.partner_econ_id ///
c.ln_dist#i.partner_econ_id ///
c.inflowsofforeignpopulation#i.partner_econ_id ///
c.col_fr#i.partner_fr ///
c.col_uk#i.partner_uk ///
c.col_us#i.partner_us ///
c.ln_servicesexp#i.partner_econ_id ///
c.ln_servicesimp#i.partner_econ_id ///
c.ln_goodsexp#i.partner_econ_id ///
c.ln_goodsimp#i.partner_econ_id ///
c.ln_fdi#i.partner_econ_id ///
c.ln_gdp#i.partner_econ_id ///
c.ln_otheraft#i.partner_econ_id ///
c.ln_oda#i.partner_econ_id ///
c.natural_resources#i.partner_econ_id, ///
absorb(reporting_econ_id year) ///
vce(cluster reporting_econ_id)
Code:
HDFE Linear regression Number of obs = 3,394
Absorbing 2 HDFE groups F( 101, 105) = 21660.24
Statistics robust to heteroskedasticity Prob > F = 0.0000
R-squared = 0.6215
Adj R-squared = 0.5958
Within R-sq. = 0.3635
Number of clusters (reporting_econ_id) = 106Root MSE = 1.5892
(Std. err. adjusted for 106 clusters in reporting_econ_id)
--------------------------------------------------------------------------------------
| Robust
ln_aft | Coefficient std. err. t P>|t| [95% conf. interval]
---------------------+----------------------------------------------------------------
partner_econ_id#|
c.hdi |
France | -8.365468 4.863386 -1.72 0.088 -18.00866 1.277727
Germany | 3.294893 4.579765 0.72 0.473 -5.785934 12.37572
Japan | -.2702511 5.346708 -0.05 0.960 -10.87179 10.33128
United Kingdom | -21.16168 8.192214 -2.58 0.011 -37.40532 -4.91803
United States | 3.296014 4.816464 0.68 0.495 -6.254144 12.84617
|
partner_econ_id#|
c.ln_gnicap |
France | 1.654401 .3692053 4.48 0.000 .9223349 2.386467
Germany | -.2690675 .3143735 -0.86 0.394 -.892412 .354277
Japan | .1885545 .4065309 0.46 0.644 -.6175211 .9946301
United Kingdom | 1.550292 .751632 2.06 0.042 .0599441 3.040639
United States | -.1473826 .3312212 -0.44 0.657 -.8041331 .5093679
|
partner_econ_id#|
c.pol_freedom |
France | -.020727 .1377542 -0.15 0.881 -.2938681 .2524141
Germany | -.2221254 .093777 -2.37 0.020 -.4080678 -.036183
Japan | -.1019459 .09783 -1.04 0.300 -.2959248 .092033
United Kingdom | -.0557523 .2033243 -0.27 0.784 -.4589068 .3474023
United States | -.0473356 .1130292 -0.42 0.676 -.2714517 .1767804
|
lldcs#|
partner_econ_id |
0#Germany | 19.686 8.013725 2.46 0.016 3.796268 35.57574
0#Japan | 33.09791 7.802076 4.24 0.000 17.62784 48.56799
0#United Kingdom | 14.82509 14.15851 1.05 0.297 -13.24861 42.89879
0#United States | 1.247056 8.29337 0.15 0.881 -15.19716 17.69128
1#France | -2.582377 8.305405 -0.31 0.756 -19.05046 13.88571
1#Germany | 17.4672 7.124526 2.45 0.016 3.34058 31.59382
1#Japan | 30.54564 7.63674 4.00 0.000 15.4034 45.68789
1#United Kingdom | 15.82774 14.82191 1.07 0.288 -13.56137 45.21685
1#United States | 0 (omitted)
|
partner_econ_id#|
c.share_world_merch |
France | 5.06e-09 1.56e-09 3.25 0.002 1.97e-09 8.15e-09
Germany | 7.84e-09 1.87e-09 4.20 0.000 4.14e-09 1.15e-08
Japan | 1.33e-09 1.75e-09 0.76 0.450 -2.14e-09 4.80e-09
United Kingdom | 4.03e-09 2.98e-09 1.35 0.180 -1.89e-09 9.94e-09
United States | -5.86e-10 1.88e-09 -0.31 0.756 -4.32e-09 3.15e-09
|
partner_econ_id#|
c. |
count_internationa~d |
France | -.1853612 .3224705 -0.57 0.567 -.8247606 .4540381
Germany | .3177221 .2043412 1.55 0.123 -.0874488 .722893
Japan | -1.002047 .3420969 -2.93 0.004 -1.680362 -.3237322
United Kingdom | 1.223445 .3890161 3.14 0.002 .4520983 1.994792
United States | .3365063 .2292649 1.47 0.145 -.1180837 .7910963
|
partner_econ_id#|
c.count_intrastate |
France | -.1750101 .2163461 -0.81 0.420 -.6039844 .2539642
Germany | -.0597992 .1261983 -0.47 0.637 -.3100271 .1904287
Japan | .1070002 .1399799 0.76 0.446 -.170554 .3845544
United Kingdom | .0940048 .2631432 0.36 0.722 -.4277596 .6157693
United States | -.0741203 .2729971 -0.27 0.787 -.6154232 .4671826
|
partner_econ_id#|
c.agree |
France | -.3751798 2.000095 -0.19 0.852 -4.341 3.59064
Germany | -.8791131 1.258728 -0.70 0.486 -3.374939 1.616713
Japan | -3.347968 1.446109 -2.32 0.023 -6.215335 -.4806007
United Kingdom | -7.730057 4.073688 -1.90 0.061 -15.80743 .3473138
United States | 1.982738 1.11721 1.77 0.079 -.2324823 4.197958
|
partner_econ_id#|
c.ln_dist |
France | 1.06597 .4135629 2.58 0.011 .2459514 1.885989
Germany | -.2094744 .2356301 -0.89 0.376 -.6766853 .2577365
Japan | -1.430836 .3959467 -3.61 0.000 -2.215925 -.6457466
United Kingdom | 3.303015 1.02918 3.21 0.002 1.26234 5.343689
United States | -.3303684 .4735732 -0.70 0.487 -1.269377 .6086397
|
partner_econ_id#|
c. |
inflowsofforeignpo~n |
France | .0000397 .0000323 1.23 0.221 -.0000242 .0001037
Germany | -4.63e-06 9.71e-06 -0.48 0.635 -.0000239 .0000146
Japan | .0000239 .0000188 1.27 0.208 -.0000135 .0000612
United Kingdom | .0000103 .000019 0.54 0.588 -.0000273 .0000479
United States | 1.34e-06 7.16e-06 0.19 0.852 -.0000129 .0000155
|
partner_fr#c.col_fr |
0 | -.0216491 .0117221 -1.85 0.068 -.0448919 .0015937
1 | 0 (omitted)
|
partner_uk#c.col_uk |
0 | .0311397 .0112371 2.77 0.007 .0088585 .0534208
1 | 0 (omitted)
|
partner_us#c.col_us |
0 | -.0453175 .0155515 -2.91 0.004 -.0761532 -.0144818
1 | 0 (omitted)
|
partner_econ_id#|
c.ln_servicesexp |
France | -.1009793 .2092745 -0.48 0.630 -.5159319 .3139733
Germany | -.207759 .1561096 -1.33 0.186 -.5172955 .1017776
Japan | -.2755614 .1402912 -1.96 0.052 -.5537329 .0026101
United Kingdom | .8352024 .433984 1.92 0.057 -.0253078 1.695713
United States | -.1605652 .185467 -0.87 0.389 -.528312 .2071815
|
partner_econ_id#|
c.ln_servicesimp |
France | .6009642 .3221383 1.87 0.065 -.0377766 1.239705
Germany | .2302156 .1748801 1.32 0.191 -.1165393 .5769705
Japan | .2120279 .1970995 1.08 0.285 -.1787841 .6028398
United Kingdom | -1.694077 .4940615 -3.43 0.001 -2.67371 -.7144445
United States | -.0054276 .1892335 -0.03 0.977 -.3806427 .3697875
|
partner_econ_id#|
c.ln_goodsexp |
France | .1951882 .097819 2.00 0.049 .0012312 .3891453
Germany | .0984622 .0580864 1.70 0.093 -.0167125 .2136368
Japan | .0798342 .0472478 1.69 0.094 -.0138493 .1735178
United Kingdom | -.1348263 .2461635 -0.55 0.585 -.6229231 .3532705
United States | .0000854 .0625908 0.00 0.999 -.1240207 .1241915
|
partner_econ_id#|
c.ln_goodsimp |
France | .1697972 .1846939 0.92 0.360 -.1964168 .5360111
Germany | .3880155 .1473953 2.63 0.010 .0957578 .6802732
Japan | .2614983 .1054035 2.48 0.015 .0525025 .470494
United Kingdom | 2.576976 .6400928 4.03 0.000 1.307791 3.846162
United States | .1719541 .1727773 1.00 0.322 -.1706314 .5145395
|
partner_econ_id#|
c.ln_fdi |
France | -.0145596 .1069726 -0.14 0.892 -.2266665 .1975473
Germany | .1115391 .0939308 1.19 0.238 -.0747083 .2977864
Japan | .0547202 .0833109 0.66 0.513 -.11047 .2199104
United Kingdom | -.2255714 .2416279 -0.93 0.353 -.7046748 .2535321
United States | .2981682 .0998416 2.99 0.004 .1002007 .4961356
|
partner_econ_id#|
c.ln_gdp |
France | .2970983 .7400153 0.40 0.689 -1.170215 1.764412
Germany | .3629671 .6773162 0.54 0.593 -.9800258 1.70596
Japan | .6390817 .6335713 1.01 0.315 -.6171731 1.895337
United Kingdom | -.2613469 .9532113 -0.27 0.784 -2.151389 1.628695
United States | .7210528 .7093308 1.02 0.312 -.6854192 2.127525
|
partner_econ_id#|
c.ln_otheraft |
France | -.3257992 .1550674 -2.10 0.038 -.6332691 -.0183292
Germany | -.4180295 .1444829 -2.89 0.005 -.7045124 -.1315466
Japan | -.3335356 .1180767 -2.82 0.006 -.5676599 -.0994112
United Kingdom | .0687922 .3324009 0.21 0.836 -.5902974 .7278818
United States | -.7653098 .162958 -4.70 0.000 -1.088425 -.4421941
|
partner_econ_id#|
c.ln_oda |
France | .5525117 .1661286 3.33 0.001 .2231093 .8819141
Germany | .4890086 .1321145 3.70 0.000 .2270501 .7509672
Japan | .183862 .1384814 1.33 0.187 -.0907211 .4584451
United Kingdom | .0938438 .2027709 0.46 0.644 -.3082134 .495901
United States | .8958777 .2354309 3.81 0.000 .4290618 1.362694
|
partner_econ_id#|
c.natural_resources |
France | .0266695 .0220096 1.21 0.228 -.0169715 .0703105
Germany | .0160756 .0178215 0.90 0.369 -.0192611 .0514123
Japan | .0079434 .0157231 0.51 0.614 -.0232325 .0391194
United Kingdom | -.039139 .1104802 -0.35 0.724 -.2582009 .1799229
United States | .0093805 .0170574 0.55 0.584 -.0244412 .0432021
|
_cons | -36.39202 14.46701 -2.52 0.013 -65.07744 -7.706611
--------------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------------+---------------------------------------|
reporting_econ_id | 106 106 0 *|
year | 11 1 10 |
-----------------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation

Comment