我正在分析三个同时运行的实验,就像这样:
df <- tibble(
treatment_1 = 1 * rbinom(1000, 1, 0.5),
treatment_2 = 2 * rbinom(1000, 1, 0.5),
treatment_3 = 3 * rbinom(1000, 1, 0.5),
covariate = rnorm(1000),
y = covariate + treatment_1 + treatment_2 + treatment_3 + rnorm(1000),
cluster = rep(1:10, each = 100),
)
我想 for each 实验估计的规格是y ~ covariate + treatment_i + i(treatment_i, covariate, ref = 0) | cluster
,当然我可以通过运行feols()
三次来实现这一点:
fixest::feols(fml = y ~ covariate + treatment_1 + i(treatment_1, covariate, ref = 0) | cluster, data = df)
fixest::feols(fml = y ~ covariate + treatment_2 + i(treatment_2, covariate, ref = 0) | cluster, data = df)
fixest::feols(fml = y ~ covariate + treatment_3 + i(treatment_3, covariate, ref = 0) | cluster, data = df)
这似乎有点低效,因为这需要我计算cluster
个固定效应三次.有没有一种方法可以使用fixest的multiple estimations functionality来估计这三种规格?