我正在使用 svydesign 分析估算数据集,但出现错误。下面是代码:
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
我正在关注此页面的教程: http ://r-survey.r-forge.r-project.org/survey/svymi.html
我如何修改代码以使其工作?
编辑:
我更改data=imputationList(imp)
为data=complete(imp,1)
并且我能够使代码工作。但是,这效率不高,因为我必须对所有估算集执行此操作。使用时有什么磨损imputationList
吗?