sampling: Random sampling

Description Usage Arguments Details Value Note Author(s) References See Also Examples

Description

Functions for random sampling.

Usage

1
2
3
4
5
6
7
8
9
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.

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é's method, respectively, for unequal probability sampling without replacement and fixed sample size.

Value

An integer vector giving the indices of the sampled observations.

Note

brewer, midzuno and tille are faster C++ implementations of UPbrewer, UPmidzuno and UPtille, respectively, from package sampling.

Author(s)

Andreas Alfons

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é, Y. (1996) An elimination procedure of unequal probability sampling without replacement. Biometrika, 83(1), 238–241.

Deville, J.-C. and Tillé, Y. (1998) Unequal probability sampling without replacement through a splitting method. Biometrika, 85(1), 89–101.

See Also

"SampleControl", "TwoStageControl", setup, inclusionProb, sample

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
## 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)

Example output

Loading required package: Rcpp
Loading required package: lattice
Loading required package: parallel
[1]  8  3  1 10  5
 [1] 5 3 2 3 3 2 3 5 1 4
[1]  8  1  4  9 10
 [1] 2 2 3 5 4 3 1 2 4 5
[1] 2 4 6
[1] 3 4 6
[1] 2 4 5

simFrame documentation built on Oct. 14, 2021, 5:24 p.m.