synth-inference / synthdid

Synthetic difference in differences
https://synth-inference.github.io/synthdid
BSD 3-Clause "New" or "Revised" License
262 stars 98 forks source link

panel.matrices complains when treatment is stored as double instead of integer? #101

Open MatthieuStigler opened 1 year ago

MatthieuStigler commented 1 year ago

If the original data contains the treatment variable stored as double instead of integer, panel.matrices will return multiple warnings: Warning in FUN(newX[, i], ...): coercing argument of type 'double' to logical.

Solution is simply to cast as integer, but maybe this could be done internally, or have an explicit message?

Thanks!

library(synthdid)

data('california_prop99')
setup = panel.matrices(california_prop99)

california_prop99$treated <- as.double(california_prop99$treated)
setup = panel.matrices(california_prop99)
#> Warning in FUN(newX[, i], ...): coercing argument of type 'double' to logical