首页 > 解决方案 > 集群自举标准错误在 R 中用于 plm 函数

问题描述

我有一个固定效应模型,只有很少的观察结果,因此想要引导以获得更准确的标准误差。同时,我假设 SE 是集群的,因此我也想纠正集群,即进行集群引导。我找到了 lm 模型 ( vcovBS) 的函数,但是找不到 plm 模型的任何内容。有人知道为固定效应模型获得集群自举 SE 的类似函数吗?

标签: rcluster-analysisstatistics-bootstrapplm

解决方案


clusterSEs 包具有用于 plm 模型的野生集群引导程序的实现:https ://www.rdocumentation.org/packages/clusterSEs/versions/2.6.2/topics/cluster.wild.plml 。

另一种包是fwildclusterboot. 它不能plm与其他两个固定效果回归包一起使用,lfe并且fixest, 并且应该比clusterSEs.

使用该fixest包,其语法如下所示:

library(fixest)
library(fwildclusterboot)

# load data set voters included in fwildclusterboot
data(voters)

# estimate the regression model via feols
feols_fit <- feols(proposition_vote ~ treatment + ideology1 + log_income + Q1_immigration , data = voters)

# bootstrap inference 
boot_feols <- boottest(feols_fit, clustid = "group_id1", param = "treatment", B = 9999)

summary(boot_feols)
#> boottest.fixest(object = lm_fit, clustid = "group_id1", param = "treatment", 
#>     B = 9999)
#>  
#>  Observations: 300
#>  Bootstr. Iter: 9999
#>  Bootstr. Type: rademacher
#>  Clustering: 1-way
#>  Confidence Sets: 95%
#>  Number of Clusters: 40
#> 
#>        term estimate statistic p.value conf.low conf.high
#> 1 treatment    0.073     3.786   0.001    0.033     0.114

推荐阅读