On Fri, 25 Jun 2021 13:54:44 -0500 Tariq Khasiri <tariqkhas...@gmail.com> wrote:
> Just trying to replicate the Callaway and Sant'Anna average treatment > group effect for my research where I would like to see how a > particular law implementation is affecting all the treated states' > wages compared to the never treated states' ( control group ) wage : > > ## 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) > > But the error I'm getting is - > > Error in var(if (is.vector(x) || is.factor(x)) x else as.double(x), > na.rm = na.rm) : > Calling var(x) on a factor x is defunct. > Use something like 'all(duplicated(x)[-1L])' to test for a constant > vector. > > Can anyone tell me what's the issue ? > > [[alternative HTML version deleted]] (1) Please don't post in html. (Read the posting guide.) (2) Where does the function att_gt() come from? It's not in base R so it is presumably from a contributed package. Don't expect your readers/helpers to be telepathic. (3) Given that it's from a contributed package, you should in the first instance contact the maintainer of the package rather than this list. Only if you get no response from the maintainer should you appeal to the list. You can find the email address of the maintainer by typing maintainer(<package name>). (4) From the error message I would guess that there is a bug in the package; it apparently uses defunct syntax in that it tries to apply var() to factors. It seems that this used to be allowed, but is no longer. But that's just a guess; I know nothing about what att_gt() is designed to do. Good luck. cheers, Rolf Turner -- Honorary Research Fellow Department of Statistics University of Auckland Phone: +64-9-373-7599 ext. 88276 ______________________________________________ R-help@r-project.org mailing list -- To UNSUBSCRIBE and more, see https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.