问题描述
只是试图在我的研究中复制 Callaway 和 Sant'Anna 平均治疗组效应,我想看看与从未治疗过的州(对照组)相比,特定法律的实施如何影响所有治疗过的州的工资工资。
但我得到的错误是 -
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),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)
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)