Quantile Estimates from Multiple Imputation (Survey Package in R)

I am currently reading "Complex Surveys: A Guide to Analysis Using R" by Thomas Lumley. I am particularly interested in the statistical methods used to address missing data in complex surveys. Chapter 9 of Lumley's book discusses the methods of two-phase estimation and multiple imputation.

I am trying to find mean and quantile estimates by combining 5 datasets that have been generated by multiple imputation (i.e. missing values imputed). More specifically, I am using data from NHANES III (available as a .db file from Lumley's website, i.e. http://r-survey.r-forge.r-project.org/svybook/), and I am trying to estimate the mean as well as the 0.5 & 0.9 quantiles for total cholesterol (chol) stratified by age (agegp) and sex (HSSEX). I am able to obtain appropriate estimates for the mean, but I get an error message when I try to calculate estimates for the quantiles (see code below).

imp <- imputationList(c("set1","set2","set3","set4","set5"),dbtype="SQLite",dbname="imp.db")
design <- svydesign(id=~SDPPSU6,strat=~SDPSTRA6,weight=~WTPFQX6,data=imp,nest=TRUE)

res_mean <- with(subset(designs,age>=20),svyby(~chol,~agegp+HSSEX,svymean))
summary(MIcombine(res_mean),digits=2)

Multiple imputation results:
with(subset(design, age >= 20), svyby(~chol,~agegp+HSSEX,svymean))
MIcombine.default(res_mean)
results  se (lower upper) missInfo
[20,40).1      191 1.2    188    193     13 %
[40,60).1      213 1.3    210    215     15 %
[60,Inf).1     212 1.3    210    215      2 %
[20,40).2      186 1.0    184    188      7 %
[40,60).2      213 1.4    211    216     12 %
[60,Inf).2     233 1.6    230    236     15 %

res_quantile <- with(subset(designs,age>=20),svyby(~chol,~agegp+HSSEX,svyquantile,quantiles=c(0.5,0.9),se=TRUE))

Error in t(sapply(results, unwrap)) :
error in evaluating the argument 'x' in selecting a method for function 't': Error in t(matrix(as.vector(object$CIs), nrow = 2)) : error in evaluating the argument 'x' in selecting a method for function 't': Error in matrix(as.vector(object$CIs), nrow = 2) :
'data' must be of a vector type, was 'NULL'


Any help would be appreciated... Thanks!

minimal reproducible example next time please

library(survey)
library(mitools)
data.dir<-system.file("dta",package="mitools")
files.men<-list.files(data.dir,pattern="m.\\.dta$",full=TRUE) men<-imputationList(lapply(files.men, foreign::read.dta)) files.women<-list.files(data.dir,pattern="f.\\.dta$",full=TRUE)
men<-update(men, sex=1)
women<-update(women,sex=0)
all<-rbind(men,women)

designs<-svydesign(id=~id, strata=~sex, data=all)

results<-with(designs, svyby(~cistot,~sex,svyquantile,c(0.5,0.9),keep.var=TRUE,se=T,ci=T))

MIcombine(results)

results2<-with(subset(designs,wave>2), svyby(~cistot,~sex,svyquantile,c(0.5,0.9),keep.var=TRUE,se=T,ci=T))

MIcombine(results2)

• Thank you! In the end, all I had to do was add ci=T (as you did). The program now runs fine. Commented Apr 28, 2017 at 17:12