#1
#Loading the dataset
data(osteoarthritis)
#Multiply imputing the missing values
imputed.datasets <- mice::mice(osteoarthritis, m = 5)
#Estimating weights of observations in the multiply imputed datasets
weighted.datasets <- weightthem(OSP ~ AGE + SEX + BMI + RAC + SMK,
imputed.datasets,
approach = 'within',
method = 'glm',
estimand = 'ATT')
#2
#Loading the dataset
data(osteoarthritis)
#Multiply imputing the missing values
imputed.datasets <- Amelia::amelia(osteoarthritis, m = 5,
noms = c("SEX", "RAC", "SMK", "OSP", "KOA"))
#Estimating weights of observations in the multiply imputed datasets
weighted.datasets <- weightthem(OSP ~ AGE + SEX + BMI + RAC + SMK,
imputed.datasets,
approach = 'within',
method = 'glm',
estimand = 'ATT')
Run the code above in your browser using DataLab