I have the following panel data:
MSO NAME time Et.1 TA D DD E NegE AC
1 1 AAA 2008 35926482695 2.713314e+11 16673656500 1 21680596142 0 68053416429
2 1 AAA 2009 89015647023 4.368508e+11 12885986626 1 35926482695 0 -16403127469
3 1 AAA 2010 69020518063 6.449785e+11 5939725272 1 89015647023 0 89813373251
4 1 AAA 2011 57619013198 8.166180e+11 10527065127 1 69020518063 0 12887655279
5 1 AAA 2012 51055385544 9.004938e+11 13051153273 1 57619013198 0 -53501519538
6 1 AAA 2013 48065653627 1.150569e+12 19781367000 1 51055385544 0 -32469058910
7 1 AAA 2014 38028443822 1.421651e+12 19761631208 1 48065653627 0 -51233881446
8 1 AAA 2015 132442586296 1.954765e+12 1935000000 1 38028443822 0 111377520972
9 1 AAA 2016 260848512270 3.077616e+12 86362442100 1 132442586296 0 52273032070
10 1 AAA 2017 196548252214 4.576157e+12 99782597750 1 260848512270 0 341512116312
11 2 AAM 2008 57941587272 3.006549e+11 8000000000 1 1322864251 0 -14925337731
12 2 AAM 2009 46383395045 3.639349e+11 17820670000 1 57941587272 0 24986657876
13 2 AAM 2010 72059294623 3.313362e+11 28349660000 1 46383395045 0 46074429603
14 2 AAM 2011 11136880296 3.299767e+11 36935083200 1 72059294623 0 41920069536
15 2 AAM 2012 8231189722 2.857607e+11 30574256000 1 11136880296 0 -12710616922
16 2 AAM 2013 9998325603 3.020715e+11 4319732500 1 8231189722 0 -10883805973
17 2 AAM 2014 2745223826 2.971910e+11 9935242150 1 9998325603 0 -8207697750
18 2 AAM 2015 1287059831 3.219338e+11 9935701000 1 2745223826 0 5320331958
19 2 AAM 2016 3186483604 2.579038e+11 5961420600 1 1287059831 0 3322154267
20 2 AAM 2017 9037301610 2.515606e+11 4967850500 1 3186483604 0 -53953958443
21 3 ABT 2008 90250633425 3.861639e+11 44219883910 1 19729732941 0 4198410342
22 3 ABT 2009 94384600568 5.370041e+11 1818000 1 90250633425 0 111477016120
23 3 ABT 2010 97594426005 6.019252e+11 45616060000 1 94384600568 0 7703020199
24 3 ABT 2011 76956934250 4.781089e+11 95873312400 1 97594426005 0 -86401093330
25 3 ABT 2012 75548007696 5.161332e+11 82627060500 1 76956934250 0 -3520346302
26 3 ABT 2013 81517685979 6.882693e+11 51669864875 1 75548007696 0 16946830605
27 3 ABT 2014 69875135594 6.566582e+11 68998242000 1 81517685979 0 48443790855
28 3 ABT 2015 49075460968 5.847154e+11 68983529175 1 69875135594 0 -63935898495
29 3 ABT 2016 29608383155 6.492765e+11 36791195040 1 49075460968 0 -44617784665
30 3 ABT 2017 66260235406 6.343462e+11 34491745350 1 29608383155 0 13811148901
I want to do a linear regression for each company. After the regression is done, I use a set of functions implementing the Newey & West (1987, 1994) heteroscedasticity and autocorrelation consistent (HAC) covariance matrix estimators.
fit2 <- lmList(Et.1 ~ TA + D + DD + E + NegE + AC | NAME, data= mh2)
NeweyWest(fit2, prewhite = FALSE)
*Error in UseMethod("estfun") :
no applicable method for 'estfun' applied to an object of class "lmList"*
Tell me how to use the NeweyWest
function for the results of the lmList
function in my data. Thank you very much.
If you use lmList, you get a list of linear models. You can do NeweyWest on say the first:
NeweyWest(fit2[[1]])
To do it on all:
lapply(fit2,NeweyWest)