I'm trying to get Newey-West standard errors to work with the output of pmg()
(Mean Groups/Fama-MacBeth estimator) from the plm
package.
Following the example from here:
require(foreign)
require(plm)
require(lmtest)
test <- read.dta("http://www.kellogg.northwestern.edu/faculty/petersen/htm/papers/se/test_data.dta")
fpmg <- pmg(y~x, test, index=c("firmid", "year")) # Time index in second position, unlike the example
I can use coeftest
directly just fine to get the Fama-MacBeth standard errors:
# Regular “Fama-MacBeth” standard errors
coeftest(fpmg)
# t test of coefficients:
#
# Estimate Std. Error t value Pr(>|t|)
# (Intercept) 0.032470 0.071671 0.453 0.6505
# x 0.969212 0.034782 27.866 <2e-16 ***
# ---
# Signif. codes: 0 ‘***’ 0.001 ‘**’ 0.01 ‘*’ 0.05 ‘.’ 0.1 ‘ ’ 1
However, trying to use the Newey-West estimators fails:
# Newey-West standard-errors
coeftest(fpmg, vcov = NeweyWest(fpmg, lag=3))
# Error in UseMethod("estfun") :
# no applicable method for 'estfun' applied to an object of class "c('pmg', 'panelmodel')"
This seems like a shortcoming in the plm
package. Do you know a way to make this work? Should I code my own estfun
for pmg
objects? Code a Newey-West estimator from scratch? Or should I bypass the plm
package altogether?
plm
has incorporated a Newey-West estimator yet, at least I do not find anything in the manual. TheNeweyWest
-function is from thesandwich
-package, which does not deal with panel data, therefore your error. You may want to have a look at this thread: r.789695.n4.nabble.com/… But I am not aware of any other panel data package. - Davidfpmg <- plm(y~x, test, index = c("firmid", "year")); coeftest(fpmg, vcov = function(x) vcovSCC(x, type = "HC1", maxlag = 4))
- Davidplm
(vspmg
) would not give me a Fama-MacBeth/Means group estimator for the coefficients, I'm afraid. - cocquemaspmg
andplm
will produce similar results. Neither am I sure that D&K produce something similar to N&W... I guess reading up will help :) But please make sure that you share the result! :D - Davidpmg
byplm
in my example above and see, unfortunately the coefficients are different. I'm reading up on D&K and will report my findings. Thanks! - cocquemas