-
Notifications
You must be signed in to change notification settings - Fork 15
Open
Description
Hi
Thanks for the package!! I notice that if the year variable is a date, and I have a never treated group, this will return an error? It seems to be due to this line:
data[is.na(data$treat_time), "treat_time"] <- 99999
As R will complain about a non-valid date?! Maybe could return a 9999-like date is year is date, or at least warn about using dates?
Thanks!
library(bacondecomp)
dat <- bacondecomp::castle[, c("l_homicide", "state", "year", "post")]
## works
df_bacon <- bacon(l_homicide ~ post,
data = dat,
id_var = "state",
time_var = "year")
#> type weight avg_est
#> 1 Earlier vs Later Treated 0.05976 -0.00554
#> 2 Later vs Earlier Treated 0.03190 0.07032
#> 3 Treated vs Untreated 0.90834 0.08796
## convert to date: does not work
dat2 <- dat
dat2$year <- as.Date(paste0("2000-01-", dat$year-1999))
unique(dat2$year)
#> [1] "2000-01-01" "2000-01-02" "2000-01-03" "2000-01-04" "2000-01-05"
#> [6] "2000-01-06" "2000-01-07" "2000-01-08" "2000-01-09" "2000-01-10"
#> [11] "2000-01-11"
bacon(l_homicide ~ post,
data = dat2,
id_var = "state",
time_var = "year")
#> Error in as.Date.numeric(value): 'origin' must be suppliedCreated on 2020-06-11 by the reprex package (v0.3.0)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels