Learn R Programming

sampling (version 2.9)

UPmultinomial: Multinomial sampling

Description

Uses the Hansen-Hurwitz method to select a sample of units (unequal probabilities, with replacement, fixed sample size).

Usage

UPmultinomial(pik)

Arguments

pik

vector of the the inclusion probabilities.

Value

Returns a vector of size N, the population size. Each element k of this vector indicates the number of replicates for unit k in the sample.

References

Hansen, M. and Hurwitz, W. (1943), On the theory of sampling from finite populations. Annals of Mathematical Statistics, 14:333-362.

Examples

Run this code
# NOT RUN {
#defines the prescribed inclusion probabilities
pik=c(0.2,0.7,0.8,0.5,0.4,0.4)
#selects a sample
s=UPmultinomial(pik)
#the selected units are
(1:length(pik))[s!=0] 
#with the number of replicates 
s[s!=0]
#or use
rep((1:length(pik))[s!=0],s[s!=0]) 
# }

Run the code above in your browser using DataLab