When I try to implement Coarsened Exact Matching with the MatchIt package I get the following error:
Error in `[[<-.data.frame`(`*tmp*`, gn[g], value = integer(0)) : replacement has 0 rows, data has 6
Here is a reproducible example:
require(MatchIt)
require(cem)
d <- data.frame(
id = 1:6 ,
treat = rep(c(1,0),each = 3),
group = c("A","B","C" , "B" , "B" , "B"))
matchit(formula = treat ~ class ,
data = d ,
grouping = list(group = list(c("A" , "B"))),
method = "cem")
I am running version 1.1.19 of cem and 3.0.2 of MatchIt.
Thank you for your help.