只是试图为我的研究复制卡拉威和圣安娜平均治疗组效应,我想看看与从未治疗过的州(对照组)工资相比,特定法律实施如何影响所有治疗州的工资。
但我得到的错误是 -
var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm) 中的错误:在因子 x 上调用 var(x) 已失效. 使用类似 'all(duplicated(x)[-1L])' 的东西来测试一个常数向量。
谁能告诉我是什么问题?我的代码如下
## Cleaning treated and never treated
dat$treat = ifelse(is.na(dat$law_effective_year),0,1)
dat$nevertreated = ifelse(dat$treat==0,1,0)
## Command for CSDID
out1 <- att_gt(yname="ln_incwage",
tname="year",
gname="law_effective_year",
xformla=~male + age + age2 + age3 + age4 + black + asian + hispanic + lths + hsdegree + somecollege ,
data=dat,
est_method = "dr", # "dr" is doubly robust. "ipw" is inverse probability weighting. "reg" is regression
control_group = "nevertreated", # set the comparison group which is either "nevertreated" or "notyettreated"
print_details = FALSE, # if TRUE, print detailed results
clustervars = "statefip", # cluster level
panel = FALSE) # wh)
summary(out1)