I am analyzing an imputed dataset using svydesign but I am getting an error. Below is the code:
library(mitools)
library(survey)
data(nhanes)
nhanes$hyp <- as.factor(nhanes$hyp)
imp <- mice(nhanes,method=c("polyreg","pmm","logreg","pmm"), seed = 23109)
des<-svydesign(id=~1, strat=~age, data=imputationList(imp))
Error in as.data.frame.default(data, optional = TRUE) : cannot coerce class ""call"" to a data.frame
I am following the tutorial from this page: http://r-survey.r-forge.r-project.org/survey/svymi.html
how do i modify the code for it to work?
EDIT:
I change data=imputationList(imp)
to data=complete(imp,1)
and i was able to make the code work. However, this is not efficient since I have to do this to all my imputed sets. Is there something worng with using imputationList
?