data(api)
## population
quantile(apipop$api00,c(.25,.5,.75))
## one-stage cluster sample
dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
svyquantile(~api00, dclus1, c(.25,.5,.75),ci=TRUE)
#stratified sample
dstrat<-svydesign(id=~1, strata=~stype, weights=~pw, data=apistrat, fpc=~fpc)
svyquantile(~api00, dstrat, c(.25,.5,.75),ci=TRUE)
# BRR method
data(scd)
repweights<-2*cbind(c(1,0,1,0,1,0), c(1,0,0,1,0,1), c(0,1,1,0,0,1),
c(0,1,0,1,1,0))
scdrep<-svrepdesign(data=scd, type="BRR", repweights=repweights)
svrepquantile(~arrests+alive, design=scdrep, quantile=0.5)
Run the code above in your browser using DataLab