I am trying to use "matchit" package with various matching options (nearest neighbor, optimal, full, etc.). They all work fine, except for one option: CEM. This is the error that I get:
m.out <- matchit(T ~ x1 + x2 + x3 + x4 + x5 + x6 + x7 + x8 + x9,
data = sample_for_matching ,method = "cem")
Using 'treat'='1' as baseline group
Error in
[.default
(tmp, x, bg) : subscript out of bounds**
Any idea why is this happening? Does it have something to do with the distribution of the variables? When I use less variables, it does work. But I need to match on all 9 variables. Thank you!!!
This is an old question but I stumbled upon the same problem and could not find a solution by googling.
I started debugging this by trying out different combinations of match variables. It turned out that the issue was caused by one of my continuous matching variables having a large number of NA's. Replacing them with zeros -- this was appropriate in my application -- resolved the issue.
The underlying issue was that the NA in one of my matching variables perfectly coincided with the treatment status.
I get the same error. It seems that this is (still) a bug in the CEM package. It is carried through to the MatchIt package, too.
The error seems to indicate that the (automatic) coarsening of the matching algorithm was not successful.
There is a bit of an older response from Stefano Iacus, one of the authors of the package on an email list, along those lines:
https://lists.gking.harvard.edu/pipermail/cem/2013-August/000120.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With