#Loading libraries
library(survey)
#Loading the dataset
data(osteoarthritis)
#Multiply imputing the missing values
imputed.datasets <- mice::mice(osteoarthritis, m = 5)
#Weighting the multiply imputed datasets
weighted.datasets <- weightthem(OSP ~ AGE + SEX + BMI + RAC + SMK,
imputed.datasets,
approach = 'within')
#Adding additional variables
weighted.datasets <- cbind(weighted.datasets,
logAGE = log(osteoarthritis$AGE))
#Using the additional variables in an analysis
models <- with(weighted.datasets,
svyglm(KOA ~ OSP + logAGE, family = quasibinomial))
#Pooling results obtained from analyzing the datasets
results <- pool(models)
summary(results)
Run the code above in your browser using DataLab