Polar Bear
Polar Bear

Reputation: 731

R: No way to get double-clustered standard errors for an object of class "c('pmg', 'panelmodel')"?

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?


Upvotes: 1

Views: 1728

Answers (1)

Giovanni Millo
Giovanni Millo

Reputation: 56

this is not a problem with the code or the SW design. The point is that (AFAIK) it does not make sense to apply vcovDC - which relies on homogeneity assumptions for the coefficents - to a heterogeneous mean groups estimator. pmg already has its (nonparametric) SEs which are robust to a range of situations. See Ibragimov and Mueller, JBES 2010. This is why the classes are, in this respect, incompatible: a SW incompatibility that mirrors a theoretical one.

Upvotes: 1

Related Questions