reznec2
reznec2

Reputation: 51

matchit CEM - "subscript out of bounds" error

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.

Upvotes: 5

Views: 985

Answers (3)

Hanifa Pilvar
Hanifa Pilvar

Reputation: 11

I had the same problem. I explored the variables that I am trying to match based on and found out that there is a variable that divide treatment and control group e.g. a>x for treatment and a<x for control group. I dropped a and the error was resolved.

Upvotes: 0

Chris Arnold
Chris Arnold

Reputation: 91

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

Upvotes: 3

Otto K&#228;ssi
Otto K&#228;ssi

Reputation: 3083

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.

Upvotes: 2

Related Questions