【发布时间】:2021-06-27 09:00:46
【问题描述】:
我有一个固定效应模型,只有很少的观察值,因此我想通过引导来获得更准确的标准误差。同时,我假设 SE 是集群的,因此我也想纠正集群,即进行集群引导。
我找到了 lm 模型的函数 (vcovBS),但是找不到 plm 模型的任何东西。有没有人知道一个类似的函数来获得固定效应模型的集群自举 SE?
【问题讨论】:
标签: r cluster-analysis statistics-bootstrap plm
我有一个固定效应模型,只有很少的观察值,因此我想通过引导来获得更准确的标准误差。同时,我假设 SE 是集群的,因此我也想纠正集群,即进行集群引导。
我找到了 lm 模型的函数 (vcovBS),但是找不到 plm 模型的任何东西。有没有人知道一个类似的函数来获得固定效应模型的集群自举 SE?
【问题讨论】:
标签: r cluster-analysis statistics-bootstrap plm
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
【讨论】: