This is a consequence of changes made to support multiple imputation, where
extracting the standard errors was needed. I will try to fix it. A work-around
is to use lapply() and subset()
lapply(c("E","M","H"), function(s)
svyquantile(~api99,subset(dclus1, stype==s), ci=TRUE,quantiles=0.5))
Thanks for reporting the problem.
-thomas
On Wed, 11 Mar 2009, Ron Burns wrote:
>
> I am having trouble understanding (i.e. getting) confidence intervals
from
> the survey package. I am using R version 2.8.1 (2008-12-22) and survey
> package (3.11-2) on FC7 linux. To simplify my question I use an example
from
> that package:
> R> data(api)
> R> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1,
fpc=~fpc)
> R> (tst <- svyby(~api99, ~stype, dclus1,
svyquantile,
> quantiles=0.5,ci=TRUE))
> stype api99 se
> E E 615 37.89
> H H 593 69.52
> M M 611 37.67
> R> str(tst)
> Classes ???svyby??? and 'data.frame': 3 obs. of 3 variables:
> $ stype: Factor w/ 3 levels "E","H","M": 1
2 3
> $ api99: num 615 593 611
> $ se : num 37.9 69.5 37.7
> - attr(*, "svyby")=List of 7
> ..$ margins : int 1
> ..$ nstats : num 1
> ..$ vars : int 1
> ..$ deffs : logi FALSE
> ..$ statistic: chr "svyquantile"
> ..$ variables: chr "api99"
> ..$ vartype : chr "se"
> - attr(*, "call")= language svyby.default(~api99, ~stype,
dclus1,
> svyquantile, quantiles = 0.5, ci = TRUE)
> R>
> I do not see the CI in this structure. Specifically, this problem came
up
> when I was working through an example where after a similar set up
> information was extracted using
> R> tst$statistics.quantiles
> NULL
> R> tst$statistics.CIs
> NULL
> where of course the NULLs I get are due, in my case, to the absences of
the
> $statistics.XXXs. The example did not display the structure so I could
not
> compare my output with their output. (The example warns that these
objects
> need to be unlisted which is not relevant here)
> Thanks in advance for any help
> Ron
> --
> R. R. Burns
> Oceanside, CA
> ______________________________________________
> R-help at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide
http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>
Thomas Lumley Assoc. Professor, Biostatistics
tlumley at u.washington.edu University of Washington, Seattle