return.replicates in survey pkg

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

return.replicates in survey pkg

Richard Valliant-2
How do I retrieve the replicates estimates from a crosstab done using
svyby?
Here is an example from the help page for svyby in the package:

> data(api)
> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
> rclus1<-as.svrepdesign(dclus1)
>
> a <- svyby(~api99, ~stype, rclus1, svymean, return.replicates=TRUE)
> a$replicates
NULL

But, compare to
> b <- svymean(~api99, design=rclus1, return.replicates=TRUE)
> b$replicates
 [1] 606.8488 611.5866 609.1989 605.5765 608.1381 606.6927 609.8101
599.4371 602.4368 601.8792 606.7531 630.6575 600.1882 607.5549 599.9942
>

The object b, created via svymean, contains "replicates" but object a,
created via svyby + svymean does not. But str(a) gives (in part)
 - attr(*, "replicates")= num [1:15, 1:3] 598 610 596 596 596 ...

which makes it look like the reps are in there somewhere. I'm using
Package survey version 3.21-2 on Windows XP.


Thanks
R. Valliant

______________________________________________
[hidden email] 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.
Reply | Threaded
Open this post in threaded view
|

Re: return.replicates in survey pkg

Thomas Lumley
On Fri, 26 Mar 2010, Richard Valliant wrote:

> How do I retrieve the replicates estimates from a crosstab done using
> svyby?
> Here is an example from the help page for svyby in the package:
>
>> data(api)
>> dclus1<-svydesign(id=~dnum, weights=~pw, data=apiclus1, fpc=~fpc)
>> rclus1<-as.svrepdesign(dclus1)
>>
>> a <- svyby(~api99, ~stype, rclus1, svymean, return.replicates=TRUE)
>> a$replicates
> NULL

Like this
> a <- svyby(~api99, ~stype, rclus1, svymean, return.replicates=TRUE)
> attr(a,"replicates")
           [,1]     [,2]     [,3]
  [1,] 598.3077 607.3676 608.6087
  [2,] 609.6923 610.8239 617.1250
  [3,] 595.7143 609.2168 616.9583
  [4,] 595.7143 606.4701 606.4091
  [5,] 595.7143 609.2817 608.6000
  [6,] 587.2308 608.3803 607.2500
  [7,] 605.4615 610.1761 610.0000
  [8,] 595.7143 600.5267 595.3182
  [9,] 554.9000 605.1571 606.3750
[10,] 595.7143 601.1364 608.6000
[11,] 591.5833 607.9688 607.9545
[12,] 622.8182 630.6491 634.8095
[13,] 595.7143 601.5746 594.5909
[14,] 595.7143 608.5315 608.6000
[15,] 590.1538 601.2593 598.1304

The help page says that the replicates are returned as an attribute of the result.  I will make it explicit that it is the "replicates" attribute of the result.

     -thomas


Thomas Lumley Assoc. Professor, Biostatistics
[hidden email] University of Washington, Seattle

______________________________________________
[hidden email] 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.