1
$\begingroup$

I am trying to use the package matchit fo propensity score matching on data set (educational stuff) with 52000 observations and a number of variables. For example, I use the command

m.out1data <- matchit(snew ~ woman + asian + black + white + other + multi + tf + fg + age + int + sd , data = nsc,method = "full")

My problem is that various methods (for example the full method) won't run because it requires a vector size larger than 2^32 -1 bytes. Other methods such as the genetic method will not complete.

I am surprised that R doesn't seem to be able to handle this because the number of sample is actually not that large. Is this to be expected or is there a simple way to trace down the issue?

$\endgroup$
1
  • $\begingroup$ Stackoverflow might be a better option. $\endgroup$ Commented Jul 21, 2021 at 20:34

1 Answer 1

1
$\begingroup$

The problem is that the distance matrix is likely around 500 million values (i.e., one for each possible pairing of treated and control). Full matching, optimal matching, and genetic matching all require the distance matrix to be computed in order to do the matching. This may simply be too big to be done effectively in R's architecture.

If you like full matching, try using subclassification ('method = "subclass"`) instead. The results tend to be similar. Remember to use a large number of subclasses (e.g., try 500 subclasses, not 5). Subclassification is extremely fast (perhaps the fastest matching method) because no distance matrix has to be created and the subclassification is done only on a single variable (the propensity score).

You can also try nearest neighbor matching. The way it is implemented in MatchIt does not involve creating the entire distance matrix. Each row of the distance matrix is created and then destroyed so less memory is used at the expense of some speed performance. It may still take some time with such a large dataset, but by setting verbose = TRUE, you can see a progress bar that will tell you how long it will take. Using variable-ratio matching or matching with replacement can mimic some of the desirable qualities of full matching. These are described in the documentation.

$\endgroup$
2
  • $\begingroup$ Thanks a lot for the response. I will try what you suggested. Is there other software around that might be able to run different methods for checking? I would think that something has to exist given the availability of large data sets these days. $\endgroup$
    – Lucas
    Commented Jul 21, 2021 at 18:08
  • $\begingroup$ Matching (without replacement) is an inherently slow process because it must be done sequentially. Optimal matching has to search through a huge problem space and so will never be faster. There has been some literature written on improving the speed of optimal matching (e.g., the fastmatch package), but I have found none of them to be faster than what is currently available. I have some plans to parallelize MatchIt where it can be, but for now I don't think there are better solutions. $\endgroup$
    – Noah
    Commented Jul 21, 2021 at 19:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.