I am estimating Fama-Macbeth regression. I have taken the code from this site
fpmg <- pmg(Mumbo~Jumbo, test, index=c("year","firmid"))
summary(fpmg)
Mean Groups model
Call:
pmg(formula = Mumbo ~ Jumbo, data = superfdf, index = c("day","Firm"))
Residuals
Min. 1st Qu. Median Mean 3rd Qu. Max.
-0.142200 -0.006930 0.000000 0.000000 0.006093 0.142900
Coefficients
Estimate Std. Error z-value Pr(>|z|)
(Intercept) -3.0114e-03 3.7080e-03 -0.8121 0.4167
Jumbo 4.9434e-05 3.4309e-04 0.1441 0.8854
Total Sum of Squares: 1.6915
Residual Sum of Squares: 0.86425
Multiple R-squared: 0.48908`
After estimating fpmg, I estimate robust SE with double-clustering:
vcovDC <- function(x, ...){
vcovHC(x, cluster="group", ...) + vcovHC(x, cluster="time", ...) -
vcovHC(x, method="white1", ...)}
coeftest(fpmg, vcov=function(x) vcovHC(x, cluster="group", type="HC1"))
I get the following error:
Error in UseMethod("estfun") :
no applicable method for 'estfun' applied to an object of class "c('pmg', 'panelmodel')"
Please suggest how to solve this error?
Update: I have also tried "multiwayvcov" package but it shows the same error. It seems that the object class is not permitted in these packages(Sandwich, multiwayvcov etc.). It seems R essentially makes all my labour useless and I have hit the dead end. I have found how to do the above in python(I mean the code) but I have no knowledge of it.
Is there no way to solve the problem in R?
estfun
is a deprecated method or you are trying to apply it to the incorrect class... I am not familiar with theplm
package, so cannot provide an exact answer. Cluster robust standard errors are available in R, as a simple google search will show you. – Goldfilled