Heteroscedasticity robust standard errors with the PLM package

Marcus R picture Marcus R · Dec 13, 2010 · Viewed 9.1k times · Source

I am trying to learn R after using Stata and I must say that I love it. But now I am having some trouble. I am about to do some multiple regressions with Panel Data so I am using the plm package.

Now I want to have the same results with plm in R as when I use the lm function and Stata when I perform a heteroscedasticity robust and entity fixed regression.

Let's say that I have a panel dataset with the variables Y, ENTITY, TIME, V1.

I get the same standard errors in R with this code

lm.model<-lm(Y ~ V1 + factor(ENTITY), data=data)
coeftest(lm.model, vcov.=vcovHC(lm.model, type="HC1))

as when I perform this regression in Stata

xi: reg Y V1 i.ENTITY, robust

But when I perform this regression with the plm package I get other standard errors

plm.model<-plm(Y ~ V1 , index=C("ENTITY","YEAR"), model="within", effect="individual", data=data)
coeftest(plm.model, vcov.=vcovHC(plm.model, type="HC1))
  • Have I missed setting some options?
  • Does the plm model use some other kind of estimation and if so how?
  • Can I in some way have the same standard errors with plm as in Stata with , robust

Answer

landroni picture landroni · Aug 14, 2014

By default the plm package does not use the exact same small-sample correction for panel data as Stata. However in version 1.5 of plm (on CRAN) you have an option that will emulate what Stata is doing.

plm.model<-plm(Y ~ V1 , index=C("ENTITY","YEAR"), model="within", 
    effect="individual", data=data)
coeftest(plm.model, vcov.=function(x) vcovHC(x, type="sss"))

This should yield the same clustered by group standard-errors as in Stata (but as mentioned in the comments, without a reproducible example and what results you expect it's harder to answer the question).

For more discussion on this and some benchmarks of R and Stata robust SEs see Fama-MacBeth and Cluster-Robust (by Firm and Time) Standard Errors in R.

See also: