#Loading libraries
library(survey)
#Loading the dataset
data(osteoarthritis)
#Multiply imputing the missing values
imputed.datasets <- mice::mice(osteoarthritis, m = 5)
#Matching in the multiply imputed datasets
matched.datasets <- matchthem(OSP ~ AGE + SEX + BMI + RAC + SMK,
imputed.datasets,
approach = 'within',
method = 'nearest')
#Analyzing the matched datasets
models <- with(matched.datasets,
svyglm(KOA ~ OSP, family = binomial),
cluster = TRUE)
#Weghting in the multiply imputed datasets
weighted.datasets <- weightthem(OSP ~ AGE + SEX + BMI + RAC + SMK,
imputed.datasets,
approach = 'within',
method = 'glm')
#Analyzing the matched datasets
models <- with(weighted.datasets,
WeightIt::glm_weightit(KOA ~ OSP,
family = binomial))
Run the code above in your browser using DataLab