Hi all,
I have a panel data for 477 firms for 2006 to 2016 and need to use two way fixed effects at the firm and year level. I need to cluster at the sector level and year level as well. The following is my dataset example using dataex.
------------------ copy up to and including the previous line ------------------
I used the following code-
xtset Firm_id year,yearly
reghdfe ROA CSI_news MCap , abs( Firm_id year) vce(cluster Sector_id year)
whereby, I got the following result-
xtset Firm_id year,yearly
panel variable: Firm_id (strongly balanced)
time variable: year, 2007 to 2016
delta: 1 year
. reghdfe ROA CSI_news MCap , abs( Firm_id year) vce(cluster Sector_id year)
(dropped 7 singleton observations)
(MWFE estimator converged in 6 iterations)
Warning: VCV matrix was non-positive semi-definite; adjustment from Cameron, Gelbach & Miller applied.
HDFE Linear regression Number of obs = 3,692
Absorbing 2 HDFE groups F( 2, 9) = 6.41
Statistics robust to heteroskedasticity Prob > F = 0.0186
R-squared = 0.7590
Adj R-squared = 0.7257
Number of clusters (Sector_id) = 37 Within R-sq. = 0.0035
Number of clusters (year) = 10 Root MSE = 7.9079
(Std. Err. adjusted for 10 clusters in Sector_id year)
------------------------------------------------------------------------------
| Robust
ROA | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
CSI_news | -.0016192 .0317118 -0.05 0.960 -.0733562 .0701178
MCap | 2.90e-06 8.26e-07 3.51 0.007 1.03e-06 4.77e-06
_cons | 3.884027 .0831247 46.73 0.000 3.695986 4.072068
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
Firm_id | 436 436 0 *|
year | 10 10 0 *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
I am not able to understand whether we need to xtset our data before using reghdfe command.
Also, when reghdfe absorb firm_id and year, that implies we have implemented fixed effects. Can I just write abs(year) for using two way fixed effects on firm_id and year.
Can someone please explain the relevance of Warning: VCV matrix, does it matter to my result as it also says that adjustment from Cameron, Gelbach & Miller applied.
Thanks, Regards
Anita
I have a panel data for 477 firms for 2006 to 2016 and need to use two way fixed effects at the firm and year level. I need to cluster at the sector level and year level as well. The following is my dataset example using dataex.
Code:
* Example generated by -dataex-. To install: ssc install dataex clear input float(Firm_id Sector_id) int year double(CSI_news LTD ROA TA ROCE TobQ MCap ROE Sales) long Employees double(RDexp RDtoNS NI) float(LoSev MedSev HiSev LoRch MedRch HiRch) 1 7 2007 0 1433.4976 3.5301 7175.4658 12.0067 .8568 1711.0215 9.4908 7638.8525 . 13.78 .1719 553.2128 0 0 0 0 0 0 1 7 2008 0 1690.6519 5.0768 9435.3135 15.7953 .9183 2271.6541 14.5885 8988.7715 . 13.78 .1719 249.9735 0 0 0 0 0 0 1 7 2009 0 4435.8189 9.3108 10887.7399 26.0305 .8454 2064.1472 27.8686 14612.5938 . 15.57 .1066 421.6511 0 0 0 0 0 0 1 7 2010 0 4384.886 7.1368 12189.4 13.7067 .9274 3659.5475 19.8623 13012.224 . 50.065 .3848 946.1162 0 0 0 0 0 0 1 7 2011 0 1362.356 6.227700000000001 13977.883 16.6953 .9051 3763.1196 16.9155 14257.145 . 46.409 .3255 823.482 0 0 0 0 0 0 1 7 2012 3 1036.958 6.7545 16598.25 26.8119 .9329 4786.7644 18.791 16322.597 . 36.092 .2211 814.813 3 0 0 0 3 0 1 7 2013 0 1174.714 7.0084 21759.858 30.3066 .9453 6373.1219 19.9668 20576.431 . 100.859 .4902 1032.631 0 0 0 0 0 0 1 7 2014 0 2625.706 6.7038 26701.309 28.7835 1.0815 10883.4887 19.9675 25983.969 . 232.428 .8945 1344.136 0 0 0 0 0 0 1 7 2015 0 4192.476 7.3423 29378.235 26.7135 1.7119 31077.9638 21.8186 28614.419 . 135.884 .4749 1624.373 0 0 0 0 0 0 1 7 2016 0 5269.4 8.7014 29664.8 23.6931 2.0644 42947.4914 23.8547 29562.1 3254 160.1 .5416 2058.77 0 0 0 0 0 0 2 35 2007 0 108351.3347 -.1857 121520.1325 -1.7557 1.5963 74708.2652 -8.7766 7186.7506 830 . . 822.6213 0 0 0 0 0 0 2 35 2008 2 130433.993 .917 146727.5216 -1.7557 1.7422 113962.8201 25.3233 40939.1998 700 . . -128.7409 0 2 0 1 1 0 2 35 2009 0 166354.6769 3.1332 198407.8058 10.2483 1.0044 15047.974 52.8925 30500.9125 541 0 0 1229.8754 0 0 0 0 0 0 2 35 2010 4 140353.8878 1.6737 173224.729 6.249 1.1849 50574.1511 17.012 33586.5716 541 0 0 5406.9342 0 4 0 0 4 0 2 35 2011 0 97128.6 .8679 160773.39 4.1316 1.0543 26813.0375 6.1452 33472.23 1604 0 0 3110.0324 0 0 0 0 0 0 2 35 2012 0 111443.71 1.9226 173684.71 14.6512 .9599 18837.6545 13.317 31629.21 1491 0 0 1449.45 0 0 0 0 0 0 2 35 2013 0 113613.63 1.0905 181885.16 10.3447 .898 11477.938 5.7919 36727.01 1494 0 0 3215.19 0 0 0 0 0 0 2 35 2014 0 110508.32 2.056 200473.93 14.1295 .9217 23146.112 10.4585 39362.55 1415 0 0 1938.73 0 0 0 0 0 0 2 35 2015 0 130877.51 2.657 209725.74 13.4244 .859 24628.864 11.0301 40408.38 1792 0 0 3930.65 0 0 0 0 0 0 2 35 2016 0 132141.89 -1.17 202290.8 13.4244 .8683 10297.622 -5.2894 33345.53 1106 0 0 5449.42 0 0 0 0 0 0 3 11 2007 0 2940.7 21.9093 70643.5 36.8216 3.1326 192277.4892 38.9604 70509.4 10032 4690 6.6516 10996.5 0 0 0 0 0 0 3 11 2008 0 2760.2 14.1371 84925.7 25.0877 1.4931 90115.4254 24.473 77196.9 9557 50.9 .0659 10775.3 0 0 0 0 0 0 3 11 2009 0 5669.2 16.86 100591.5 28.128 2.0448 163794.0178 29.2478 84795.5 9557 36.2 .0427 10592.8 0 0 0 0 0 0 3 11 2010 2 5239.6 10.2133 110413.4 16.4017 2.2601 201938.9049 17.7361 82587.7 9557 52.1 .0631 11618.2 2 0 0 0 2 0 3 11 2011 2 5107.3 11.3815 118167.1 18.6017 2.2157 213447.6952 19.6202 100123.3 9031 63 .0629 6582.9 0 2 0 0 2 0 3 11 2012 20 850.3 8.9222 119281.8 14.732 2.6362 268888.8989 14.762 113581.9 9769 82.4 .0725 . 8 12 0 0 18 2 3 11 2013 8 0 9.1111 121010.6 15.0517 2.0745 208162.6635 14.417 111694.2 9658 84.9 .076 . 8 0 0 0 8 0 3 11 2014 12 0 9.3761 126816.3 15.0517 2.4249 262871.6602 14.4946 117387.9 9071 94.1 .0802 . 0 12 0 12 0 0 3 11 2015 14 0 4.612 127999.6 8.6114 2.3379 255455.7186 7.063 117971.6 9071 0 0 . 2 12 0 9 5 0 3 11 2016 0 0 5.0263 133939.4 9.4065 2.2082 249954.2364 7.6392 107677.9 9071 0 0 . 0 0 0 0 0 0 4 38 2007 0 0 . 98.1509 . 1.5258 102.912 . .4616 . . . -2.0761 0 0 0 0 0 0 4 38 2008 0 0 -25.5354 70.0807 . 1.7215 102.912 -41.4454 1.2044 . . . -21.4793 0 0 0 0 0 0 4 38 2009 0 0 .7166 53.116 . 1.9437 102.912 .8398 1.1511 . . . .4414 0 0 0 0 0 0 4 38 2010 0 0 .3636 180.156 . .9235 165.5808 .3654 .3011 . 0 0 .4241 0 0 0 0 0 0 4 38 2011 0 0 .5027 258.8283 . 1.2365 310.282 .5151 0 . 0 0 1.1034 0 0 0 0 0 0 4 38 2012 0 0 .0176 275.2711 . .3206 62.0564 .0188 0 . 0 0 .0469 0 0 0 0 0 0 4 38 2013 0 0 -.1053 260.4517 . .1118 17.7304 -.1132 8.725999999999999 . 0 0 -.282 0 0 0 0 0 0 4 38 2014 0 0 -.1053 260.4517 . .1118 17.7304 -.1132 5.288 . 0 0 .013 0 0 0 0 0 0 4 38 2015 0 0 -.1053 260.4517 . .1118 17.7304 -.1132 41.47 . 0 0 -142.96 0 0 0 0 0 0 4 38 2016 0 0 -.1053 260.4517 . .1118 31.0282 -.1132 52.79 . 0 0 -.08 0 0 0 0 0 0 5 24 2007 0 40664.4 2.8132 79101.5 12.2554 1.5091 51774.5891 17.2816 152370.1 610 . . 1345.8 0 0 0 0 0 0 5 24 2008 3 61041.2 3.6381 124161.2 10.8354 2.0194 147818.2389 22.5767 196097.1 610 . . 1730.8 3 0 0 0 3 0 5 24 2009 2 120842.4 3.0985 201577.4 7.949 1.1777 66004.9457 19.6214 262582.8 505 0 0 3697.5 2 0 0 0 2 0 5 24 2010 7 174388.5 3.6293 305026.2 6.7691 1.569 233923.0705 20.3012 258898.7 391 0 0 5046.5 7 0 0 0 7 0 5 24 2011 29 242524.8 5.2643 635677.7 9.6102 1.8744 733078.4108 20.8388 196312.9 478 0 0 9193 15 14 0 8 19 2 5 24 2012 26 488943 2.1569 1069740.2 5.2693 1.1314 335277.1038 9.8886 311646.6 597 0 0 24760.9 17 9 0 2 23 1 5 24 2013 34 488501.3 1.4715 1122585 4.2545 1.0069 222381.5988 7.8816 367296.5 597 0 0 18392.1 9 25 0 7 27 0 5 24 2014 108 495842.3 1.9268 1182537.4 4.2545 1.1414 404730.1105 9.823 550668.8 597 0 0 16129.8 30 78 0 17 69 22 5 24 2015 94 554867.6 1.564 1308585.7 10.3397 1.3206 676768.1346 7.8733 643979.2 597 0 0 22207.7 32 62 0 30 53 11 5 24 2016 12 70090.4 1.1711 417560.9 4.511 .874 81165.9841 5.1692 337862.8 597 0 0 19480.5 6 6 0 4 6 2 6 42 2007 0 20680.187 4.7196 58969.946 7.2475 4.4886 231892.8671 12.5066 8170.23 665 . . 1918.8 0 0 0 0 0 0 6 42 2008 0 26350.264 6.6509 71094.988 10.7234 2.4104 129539.4625 15.6032 11880.477 665 0 0 2104.181 0 0 0 0 0 0 6 42 2009 0 24426.183 8.5452 87122.604 13.3311 4.2353 316375.9963 21.1984 13821.341 665 0 0 4325.244 0 0 0 0 0 0 6 42 2010 0 17168.547 10.0706 95219.282 16.2561 3.4354 273763.8038 24.0412 19371.705 665 0 0 6759.994 0 0 0 0 0 0 6 42 2011 0 154462.4 6.2197 259160.7 10.2052 1.8154 259439.5359 24.4917 26358.4 665 0 0 9181.465 0 0 0 0 0 0 6 42 2012 4 102575 6.9109 210595.9 11.8444 2.0598 287116.1597 28.9707 34864.2 665 0 0 11020.7 2 2 0 0 4 0 6 42 2013 11 112884.1 7.6072 246771.6 15.0987 2.2172 388031.1762 22.9523 45813.2 665 0 0 16232.2 6 5 0 0 11 0 6 42 2014 23 138497.8 8.1549 320821.9 17.6157 2.6531 637989.9093 23.6998 58937.8 665 0 0 17396.4 1 22 0 4 16 3 6 42 2015 8 158196.7 8.197 386059.9 20.7432 1.9832 512974.7512 24.0382 71086.5 665 0 0 23143.3 8 0 0 0 8 0 6 42 2016 4 179932.4 9.5181 435850.8 23.0932 2.2153 703295.218 25.4825 84393.5 665 0 0 28971.6 0 4 0 4 0 0 7 48 2007 0 . . . . . . . . . . . . 0 0 0 0 0 0 7 48 2008 0 10111.74 . 28811.2 . . . . . 651 . . -71.79 0 0 0 0 0 0 7 48 2009 2 40896.865 -.0924 79102.981 . . . -.2792 . 651 . . -49.868 2 0 0 0 2 0 7 48 2010 1 100220.095 1.3167 179280.4 1.8618 2.0883 252884.0832 4.2175 4348.609 651 0 0 1701.066 1 0 0 0 1 0 7 48 2011 5 216878.2 1.941 349891.8 1.8618 1.5228 245798.9688 8.5132 21351.9 651 0 0 5135.7 3 2 0 3 2 0 7 48 2012 8 295848.3 -.6652 513837.4 -2484.1855 1.173 149332.4112 -4.6602 40921.6 651 0 0 -2872.7 5 3 0 2 5 1 7 48 2013 0 331916 -4.3273 546878.6 -2484.1855 1.0994 97286.5113 -44.4136 67793.6 651 0 0 -22950.1 0 0 0 0 0 0 7 48 2014 28 331314.8 -.5123 587389.4 -2484.1855 1.1262 139575.4145 -5.3623 154639 651 0 0 -2905.5 7 21 0 9 12 7 7 48 2015 7 350896.6 -1.3917 584742.2 -2484.1855 1.1344 135841.9158 -13.2969 188237.3 1438 0 0 -8156.3 3 4 0 2 5 0 7 48 2016 6 354175.5 .8204 757942.1 -2484.1855 1.053 114854.1965 8.3502 251983.2 1237 0 0 5508 2 4 0 4 2 0 8 7 2007 0 909.417 10.842 3287.751 16.6222 .8634 1029.006 26.0001 1430.203 . 2 .1398 261.446 0 0 0 0 0 0 8 7 2008 0 592.009 12.312 3509.5891 18.7512 .8789 1549.3556 24.2422 1742.722 405 2 .1398 336.367 0 0 0 0 0 0 8 7 2009 0 461.716 13.0436 3641.358 17.7699 .569 830.2208 21.326 2048.932 378 .859 .0419 418.443 0 0 0 0 0 0 8 7 2010 3 440.544 13.9557 4024.989 16.6976 .7331 1819.4697 20.213 2243.251 361 6.697 .2985 466.37 3 0 0 0 3 0 8 7 2011 0 138 14.8424 4369.817 18.4844 .8885 3033.229 19.426 2362.497 356 8.611 .3645 534.946 0 0 0 0 0 0 8 7 2012 2 6822.875 .497 12910.771 3.688 .8726 1957.4501 1.2057 6090.804 929 18.25 .2996 622.996 2 0 0 0 2 0 8 7 2013 0 5859.375 1.4305 14560.682 5.8398 .8665 1827.655 5.3294 7552.084 929 18.25 .2996 42.94 0 0 0 0 0 0 8 7 2014 0 7331.875 3.0748 17795.174 9.0215 .9908 4064.5737 12.437 10661.625 1227 19.565 .1835 196.488 0 0 0 0 0 0 8 7 2015 0 6703.125 2.0581 18445.405 6.671 1.0336 5079.5478 8.5849 11256.991 1219 48.1 .4273 497.436 0 0 0 0 0 0 8 7 2016 0 . . . . . . . . . . . . 0 0 0 0 0 0 9 14 2007 0 431.9204 5.2647 1535.7039 . 1.2815 708.3998 33.1934 694.4789 . . . 100.7345 0 0 0 0 0 0 9 14 2008 0 0 11.8286 2087.4751 . 1.53 1544.829 53.7666 1251.5692 . . . 82.4457 0 0 0 0 0 0 9 14 2009 0 0 .6883 1417.2771 . 1.0965 584.47 2.722 764.6258 . . . 214.2861 0 0 0 0 0 0 9 14 2010 0 250 6.3201 2596.3509 . 1.8477 2775.54 24.8168 1171.7255 1525 . . 12.0616 0 0 0 0 0 0 9 14 2011 0 0 -3.5792 2118.4392 . 1.3566 1365.61 -14.2451 1236.1055 1203 . . 126.8335 0 0 0 0 0 0 9 14 2012 0 0 -7.9531 2366.2806 . 1.15 786.68 -34.233 970.0711 930 . . -84.3751 0 0 0 0 0 0 9 14 2013 2 0 -7.0148 1999.4749 . 1.2695 897.48 -38.744 938.3737 897 . . -178.3378 2 0 0 0 2 0 9 14 2014 0 0 -5.704 2116.162 . 1.2342 736.82 -39.1303 813.0967 896 . . -153.1246 0 0 0 0 0 0 9 14 2015 0 0 2.6818 2283.0702 . 1.489 1332.37 25.8028 1263.5865 930 . . -117.379 0 0 0 0 0 0 9 14 2016 0 0 1.3769 2549.6741 . 1.3564 1157.86 14.3042 1275.3708 930 . . 58.9896 0 0 0 0 0 0 10 16 2007 2 3030.6631 5.3447 9822.502 28.1466 2.6929 21160.9657 15.6775 4021.394 128 . . 504.975 0 2 0 2 0 0 10 16 2008 0 3858.548 4.7297 11530.767 27.2532 1.398 9187.0928 11.0613 5844.352 128 437.28 7.4821 -274.529 0 0 0 0 0 0 10 16 2009 0 3760.417 2.217 12871.891 27.2532 1.3197 9224.1443 5.5735 6505.868 128 533.774 8.2045 593.627 0 0 0 0 0 0 10 16 2010 0 5585.793 -2.062 13755.314 27.2532 1.11 6541.115 -5.4166 6535.745 128 674.45 10.3194 835.388 0 0 0 0 0 0 10 16 2011 0 4792.264 .8468 15273.373 11.582 .902 3921.5139 2.3531 9118.114 128 722.036 7.9187 1527.253 0 0 0 0 0 0 10 16 2012 0 4496.143 3.8275 15745.929 30.8171 1.6675 16175.9287 10.7111 10277.281 630 931.316 9.0619 . 0 0 0 0 0 0 10 16 2013 0 4621.779000000001 2.4447 20648.428 30.6894 1.1718 9762.6444 7.4889 11792.825 640 1094.825 9.2838 . 0 0 0 0 0 0 10 16 2014 0 4638.296 3.9587 21556.888 30.6894 2.0474 30061.3873 12.1967 14315.368 667 1222.182 8.5376 . 0 0 0 0 0 0 10 16 2015 0 4638.296 3.9587 21556.888 30.6894 2.0474 46507.5105 12.1967 12014.782 667 1222.182 8.5376 . 0 0 0 0 0 0 10 16 2016 0 1963.995 3.9587 23754.767 30.6894 2.7455 50423.1005 12.1967 12446.507 667 1222.182 8.5376 . 0 0 0 0 0 0 end format %ty year
I used the following code-
xtset Firm_id year,yearly
reghdfe ROA CSI_news MCap , abs( Firm_id year) vce(cluster Sector_id year)
whereby, I got the following result-
xtset Firm_id year,yearly
panel variable: Firm_id (strongly balanced)
time variable: year, 2007 to 2016
delta: 1 year
. reghdfe ROA CSI_news MCap , abs( Firm_id year) vce(cluster Sector_id year)
(dropped 7 singleton observations)
(MWFE estimator converged in 6 iterations)
Warning: VCV matrix was non-positive semi-definite; adjustment from Cameron, Gelbach & Miller applied.
HDFE Linear regression Number of obs = 3,692
Absorbing 2 HDFE groups F( 2, 9) = 6.41
Statistics robust to heteroskedasticity Prob > F = 0.0186
R-squared = 0.7590
Adj R-squared = 0.7257
Number of clusters (Sector_id) = 37 Within R-sq. = 0.0035
Number of clusters (year) = 10 Root MSE = 7.9079
(Std. Err. adjusted for 10 clusters in Sector_id year)
------------------------------------------------------------------------------
| Robust
ROA | Coef. Std. Err. t P>|t| [95% Conf. Interval]
-------------+----------------------------------------------------------------
CSI_news | -.0016192 .0317118 -0.05 0.960 -.0733562 .0701178
MCap | 2.90e-06 8.26e-07 3.51 0.007 1.03e-06 4.77e-06
_cons | 3.884027 .0831247 46.73 0.000 3.695986 4.072068
------------------------------------------------------------------------------
Absorbed degrees of freedom:
-----------------------------------------------------+
Absorbed FE | Categories - Redundant = Num. Coefs |
-------------+---------------------------------------|
Firm_id | 436 436 0 *|
year | 10 10 0 *|
-----------------------------------------------------+
* = FE nested within cluster; treated as redundant for DoF computation
I am not able to understand whether we need to xtset our data before using reghdfe command.
Also, when reghdfe absorb firm_id and year, that implies we have implemented fixed effects. Can I just write abs(year) for using two way fixed effects on firm_id and year.
Can someone please explain the relevance of Warning: VCV matrix, does it matter to my result as it also says that adjustment from Cameron, Gelbach & Miller applied.
Thanks, Regards
Anita