[R] Error in var(if (is.vector(x) || is.factor(x)) x else as.double(x), na.rm = na.rm)

Duncan Murdoch murdoch@dunc@n @end|ng |rom gm@||@com
Sat Jun 26 10:45:45 CEST 2021


This is a duplicate of your SO post:

https://stackoverflow.com/questions/68135737/error-in-varif-is-vectorx-is-factorx-x-else-as-doublex

There you were asked for some data to make it reproducible.  You 
shouldn't assume that people here are any more clairvoyant than the SO 
readers.

Duncan Murdoch

On 25/06/2021 2:54 p.m., Tariq Khasiri 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]]
> 
> ______________________________________________
> R-help using 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.
>



More information about the R-help mailing list