Learn R Programming

simFrame (version 0.5.4)

sampling: Random sampling

Description

Functions for random sampling.

Usage

srs(N, size, replace = FALSE)

ups(N, size, prob, replace = FALSE)

brewer(prob, eps = 1e-06)

midzuno(prob, eps = 1e-06)

tille(prob, eps = 1e-06)

Arguments

N

a non-negative integer giving the number of observations from which to sample.

size

a non-negative integer giving the number of observations to sample.

prob

for ups, a numeric vector giving the probability weights (see sample). For tille and midzuno, a vector of inclusion probabilities (see inclusionProb).

replace

a logical indicating whether sampling should be performed with or without replacement.

eps

a numeric control value giving the desired accuracy.

Value

An integer vector giving the indices of the sampled observations.

Details

srs and ups are wrappers for simple random sampling and unequal probability sampling, respectively. Both functions make use of sample.

brewer, midzuno and tille perform Brewer's, Midzuno's and Till<U+00E9>'s method, respectively, for unequal probability sampling without replacement and fixed sample size.

References

Brewer, K. (1975), A simple procedure for sampling \(\pi\) pswor, Australian Journal of Statistics, 17(3), 166-172.

Midzuno, H. (1952) On the sampling system with probability proportional to sum of size. Annals of the Institute of Statistical Mathematics, 3(2), 99--107.

Till<U+00E9>, Y. (1996) An elimination procedure of unequal probability sampling without replacement. Biometrika, 83(1), 238--241.

Deville, J.-C. and Till<U+00E9>, Y. (1998) Unequal probability sampling without replacement through a splitting method. Biometrika, 85(1), 89--101.

See Also

"'>SampleControl", "'>TwoStageControl", setup, inclusionProb, sample

Examples

Run this code
# NOT RUN {
## simple random sampling
# without replacement
srs(10, 5)
# with replacement
srs(5, 10, replace = TRUE)

## unequal probability sampling
# without replacement
ups(10, 5, prob = 1:10)
# with replacement
ups(5, 10, prob = 1:5, replace = TRUE)

## Brewer, Midzuno and Tille sampling
# define inclusion probabilities
prob <- c(0.2,0.7,0.8,0.5,0.4,0.4)
# Brewer sampling
brewer(prob)
# Midzuno sampling
midzuno(prob)
# Tille sampling
tille(prob)
# }

Run the code above in your browser using DataLab