FarhadPishgar / MatchThem

Matching and Weighting Multiply Imputed Datasets
12 stars 2 forks source link

Matched Datasets not being output #3

Closed ABorakati closed 4 years ago

ABorakati commented 4 years ago

Hi,

I've generated some imputed datasets and have run the matchthem function on them: matchthem( XRPositive ~ Sex + Age + Comorbidity + Ethnicity + RR, data = imputed, method = 'nearest', verbose = TRUE, replace = FALSE, ratio = 1, caliper = 0.2, m.order = "random", ) -> matched2

However the output, matched two although I can see it has done matching and stored this info in the 'models' sublist, the datasets that are output in 'matched2' are simply the unmatched datasets, i.e. the unmatched imputed datasets each had 1198 observations, the datasets in matched2 also have 1198 although the models section indicates each matched dataset should only have 800-900 observations,

How do I get the matched datasets only?

Many thanks

FarhadPishgar commented 4 years ago

Hi. Thanks for reaching out. You should use the complete() function. For example, if you want to extract the fourth matched dataset:

dataset4 <- complete(data = matched2, n = 4, all = FALSE)

Please see the reference manual, the complete() function, for more details here. However, I highly suggest to use the with() and pool() for your analysis. Please see the package cheatsheet here for more details.

Thanks,

ABorakati commented 4 years ago

Hello, I have tried this, complete(), with(), pool() all act on the full imputed dataset without matching

FarhadPishgar commented 4 years ago

With all = FALSE?

FarhadPishgar commented 4 years ago

By the way, the with() will automatically select the matched datasets. There is no need to select anything or specify any arguments for that, for example:

results <- with(data = matcheddatasets, exp = svyglm(outcome ~ exposure, family = binomial))

and

pooledresults <- pool(results)

Please let me know if it worked.

ABorakati commented 4 years ago

Thanks a lot, that worked, I didn't know with() automatically selected the matched data, won't have to run my models again in that case!

I've been trying to get some summary statistics as well and I think easier with complete() and extracting the matched datasets

PS Your package is great, saves so much time!

FarhadPishgar commented 4 years ago

Thanks!