0

I am using the R package MatchThem to match a dataset that contains 19 control samples and 13 case samples. After running the MatchThem command with nearest-neighbor one-to-one matching without replacement, I see in the summary that the matched sample should now contain 13 controls and 13 cases. I wanted to extract the matched sample dataset so that I can use other functions on this sample (e.g. survival analysis, summary table with gtsummary, etc.), and learned that the complete() function serves this purpose.

However, after running the complete() function and checking the data frame, I see that this (supposedly) matched sample contains 19 controls and 13 cases, just like the initial dataset before matching!

What is the proper way of extracting the matched sample with 13 controls and 13 matched cases?

  • 1
    Welcome to SO, SesameCat! Questions on SO (especially in R) do much better if they are reproducible and self-contained. By that I mean including attempted code (please be explicit about non-base packages), sample representative data (perhaps via `dput(head(x))` or building data programmatically (e.g., `data.frame(...)`), possibly stochastically), perhaps actual output (with verbatim errors/warnings) versus intended output. Refs: https://stackoverflow.com/q/5963269, [mcve], and https://stackoverflow.com/tags/r/info. – r2evans Jun 12 '23 at 00:59

1 Answers1

0

Please read the documentation for MatchThem::complete(). The all argument controls whether all units are included or whether those with zero weights (i.e., those that have not been matched) are dropped. Setting all = FALSE will only return matched units.

By the way, don't think you can learn anything from a sample of 26 units that have missing values. That is way too small an sample for anything meaningful to arise.

Noah
  • 3,437
  • 1
  • 11
  • 27