2
votes

I was looking for a way to do clustered standard errors based on ID-Year clusters (each ID-Year combination gets treated like a new cluster). I found that no such functions exist for plm objects, but I had an idea and I would like to know whether it makes sense:

In my plm formula, let's say I have

p <- plm(y~x+factor(year), df, model="within", index=("ID","Date"), effect="individual")

pce <- coeftest(p, vcov=vcovHC(p, method = "arellano", type="sss",cluster="group"))

Could I simply assign a LSDV model with an index which simply represents ID-Year combinations like this:

df$IDYEAR <- paste(df$ID,df$YEAR)

p1 <- plm(y~x+factor(year)+factor(ID), df, model="pooling", index=("IDYEAR"))

p1ce <- coeftest(p1, vcov=vcovHC(p1, method = "arellano", type="sss",cluster="group"))

This should estimate almost exactly the same model while tricking my plm function into thinking that the group level is IDYEAR so that I get the right standard errors. Is my thinking correct here?

1
Did you check if vcovDC does what you want?Helix123
Hey, thanks for your quick tipp. vcovDC seemed similar to me but it produces in NAs in some standard errors, which is probably because it takes my "Date" index as the argument for its second way of clustering. I would rather cluster on a yearly basis since a)I think it produces the NAs and b) I see no economic reason to treat each individual on each day differently. Do you have an idea to feed it with different variables? Simply setting the index of the within model to "ID","YEAR" produces an error. (Error in pdim.default(index[[1]], index[[2]]) : duplicate couples (id-time))Jan Felix
Maybe you can have a look at other vcov packages, e.g. multiwayvcovHelix123
An excellent overview of the flexible covariance estimators in plm is given in the recent overview in JSS: dx.doi.org/10.18637/jss.v082.i03 If you can take a pooling approach, you might also estimate the model with lm() and then use vcovCL() from the sandwich package (see EconPapers.repec.org/RePEc:inn:wpaper:2017-12) which has incorporated much of the multiwayvcov functionality in its most recent version.Achim Zeileis
Thank you for your replies! I will take a look, so far I still haven't found any other answers :)Jan Felix

1 Answers

1
votes

I think, a minor adjustment to vcovDC should do

    vcovDC <- function(x, ...){
    vcovHC(x, cluster="group", ...) + vcovHC(x, cluster="time", ...) - 
        vcovHC(x, method="white1", ...)
}

Pretty neat explanation here.

This should work for your LSDV example, too.