R Sandwich 包是否没有生成预期的集群稳健标准错误?
Is R Sandwich package not generating the expected clustered robust standard errors?
加载数据
utils::data("InstInnovation", package = "sandwich")
df <- InstInnovation
创建组变量组合 'company' 和 'year'
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.com/cran/sandwich
非常感谢您。
cluster=~company+year
确实有些不同:'multiway clustering'。我在这里找到了解释:
http://fmwww.bc.edu/repec/bost10/BOS10.baum.pdf
https://francish.netlify.app/post/note-on-robust-standard-errors/
加载数据
utils::data("InstInnovation", package = "sandwich")
df <- InstInnovation
创建组变量组合 'company' 和 'year'
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.com/cran/sandwich
非常感谢您。
cluster=~company+year
确实有些不同:'multiway clustering'。我在这里找到了解释:
http://fmwww.bc.edu/repec/bost10/BOS10.baum.pdf
https://francish.netlify.app/post/note-on-robust-standard-errors/