R plm对阵Stata reghdfe

时间:2018-12-06 15:41:39

标签: r stata plm

在Stata中估计面板数据模型(使用社区贡献命令libswiftSwiftOnoneSupport.dylib)与R.时,我发现稍微不同的结果。

状态:

class Test {
    func a() { print ("something") }
}

R:

libswiftSwiftOnoneSupport.dylib

我本来希望系数相同(我猜标准误差也仍然需要自由度校正)。我想念什么?

1 个答案:

答案 0 :(得分:0)

稍作调整后,我发现R的plm包可以使用多种固定效果(至少在两个索引级别上)

## estimate the model
model5 = plm( ln_wage ~   grade + age + ttl_exp + tenure+    not_smsa  + south + as.factor(year), data=df, index=c('idcode',  'year'), model="with", effect="time")
summary(model5)[1:7,1:4]  #  <- this gives unclustered errors
coeftest(model5, vcov=vcovHC(model5,type="HC0",cluster="group"))   [1:7,1:4] # <- this gives clustered errors

以上内容等同于固定时间效果,并且在数值上类似于Statas reghdfe命令

 reghdfe ln_w grade age ttl_exp tenure not_smsa south, abs(year)  cluster(idcode)

类似地,如果您想要两种固定效果,都可以在Stata中找到:

 reghdfe ln_w grade age ttl_exp tenure not_smsa south, abs(idcode year)  cluster(idcode) 

在R中,您可以使用:

model5 = plm( ln_wage ~   grade + age + ttl_exp + tenure+    not_smsa  + south + as.factor(year), data=df, index=c('idcode',  'year'), model="with", effect="twoways")
summary(model5)  #  <- this gives unclustered errors
coeftest(model5, vcov=vcovHC(model5,type="HC0",cluster="group"))    # <- this gives clustered errors