Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

matchit CEM - "subscript out of bounds" error

Tags:

r

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!!!

like image 1000
reznec2 Avatar asked May 07 '18 10:05

reznec2


2 Answers

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.

like image 119
Otto Kässi Avatar answered Oct 21 '22 22:10

Otto Kässi


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

like image 2
Chris Arnold Avatar answered Oct 21 '22 21:10

Chris Arnold