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?
vcovDC
does what you want? – Helix123Error in pdim.default(index[[1]], index[[2]]) : duplicate couples (id-time)
) – Jan Felixmultiwayvcov
– Helix123plm
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 withlm()
and then usevcovCL()
from thesandwich
package (see EconPapers.repec.org/RePEc:inn:wpaper:2017-12) which has incorporated much of themultiwayvcov
functionality in its most recent version. – Achim Zeileis