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

Tariq Khasiri t@r|qkh@@|r| @end|ng |rom gm@||@com
Fri Jun 25 20:54:44 CEST 2021

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",
               xformla=~male + age + age2 + age3 + age4 + black + asian +
hispanic + lths + hsdegree + somecollege ,
               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)


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

Can anyone tell me what's the issue ?

	[[alternative HTML version deleted]]

More information about the R-help mailing list