[R] survey weights in sample with replacement

Thomas Lumley tlumley at u.washington.edu
Wed Oct 31 15:43:52 CET 2007


On Tue, 30 Oct 2007, Azam, Mehtabul  wrote:

>>> Hi,
>       I am trying to draw a random sample from an household survey with 
> sample weight. Is there any function in R or Splus which allows this.
>

It depends on exactly what you want.

The sample() function will draw unequal probability samples with 
replacement.

sample() will also draw samples without replacement, but (as documented) 
it uses sequential sampling and so does not actually generate 
probabilities proportional to the specified weights for sample sizes 
greater than 1.

The error in sequential sampling is pretty small, but it has attracted a 
lot of creativity in the survey literature (probably more than it 
deserves).  The 'sampling' package implements several algorithms for 
drawing unequal probability samples without replacement that really are 
proportional to the specified weights where this is achievable.

 	-thomas

Thomas Lumley			Assoc. Professor, Biostatistics
tlumley at u.washington.edu	University of Washington, Seattle



More information about the R-help mailing list