I'm trying to run a regression in R's plm
package with fixed effects and model = 'within'
, while having clustered standard errors. Using the Cigar
dataset from plm
, I'm running:
require(plm)
require(lmtest)
data(Cigar)
model <- plm(price ~ sales + factor(state), model = 'within', data = Cigar)
coeftest(model, vcovHC(model, type = 'HC0', cluster = 'group'))
Estimate Std. Error t value Pr(>|t|)
sales -1.21956 0.21136 -5.7701 9.84e-09
This is (slightly) different than what I'd get by using Stata (having written the Cigar file as a .dta):
use cigar
xtset state year
xtreg price sales, fe vce(cluster state)
price Coef. Std. Err. t P>t [95% Conf. Interval]
sales -1.219563 .2137726 -5.70 0.000 -1.650124 -.7890033
Namely, the standard error and T statistic are different. I've tried rerunning the R code with different "types", but none give the same result as Stata. Am I missing something?