我试图在R的plm
包中使用固定效果和model = 'within'
运行回归,同时发生了群集标准错误。从plm
使用Cigar
数据集,我运行:使用plm(带有固定效应)的R中的聚集标准错误
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
这是(略)比我用的Stata得到不同(写过雪茄文件作为.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
即,标准误差和T统计量是不同的。我试过用不同的“类型”重新运行R代码,但没有一个与Stata有相同的结果。我错过了什么吗?
看起来是工作(如果我使用类型HC1)。谢谢! – user5450835
@ user5450835好的!让我编辑帖子。 –
@ user5450835请选择此项作为解决问题的答案。 –