utils::data("InstInnovation", package = "sandwich")
df <- InstInnovation
df[['cluster_var']] <- factor(paste0(df$company,"-",df$year))
model <- lm(sales ~ competition + log(capital/employment) + year, data = df)
lmtest::coeftest(model, vcov = vcovCL(model, type="HC3", cluster=~company+year))
lmtest::coeftest(model, vcov = vcovCL(model, type="HC3", cluster=~cluster_var))
不应该 cluster=~company+year
和 cluster=~cluster_var
是等价的吗?
另外,我找不到一个地方(如Github)来报告R sandwich包的问题,我找到了这个,但只是一个只读的镜像。https:/github.comcransandwich。
先谢谢你了。
cluster=~company+year
确实是不同的东西:"多向聚类"。我在这里找到了解释。