samprop {sampfling}R Documentation

Random Sampling: the Sampford Algorithm

Description

samprop implements a modified version of the Sampford algorithm to obtain a sample without replacement and with unequal probabilities. The probability of the sample is proportional to the product of the probabilities of units contained in the sample.

Usage

 samprop(x, size, prob = NULL)

Arguments

x Either a (numeric, complex, character or logical) vector of more than one element from which to choose, or a positive integer.
size A positive integer giving the number of items to choose.
prob A vector of weights for obtaining the elements of the vector being sampled.

Details

If x has length 1, sampling takes place from 1:x.

The prob argument gives a vector of weights for obtaining the elements of the vector being sampled. They need not sum to one, but they should be nonnegative. The number of nonzero weights must be at least size. Each weight cannot exceed a certain quantity, in order to satisfy Sampford algorithm requirements (see sampfle).

This procedure draws a sample without replacement, which probability is proportional to the product of weights of units contained in the sample.

Value

A vector of size size, which contains the sampled units from x, or indices if x is an integer.

Author(s)

Carlos Enrique Carleos Artime carleos@vodafone.es.

References

Cochran, W.G. (1977) Sampling techniques, John Wiley and Sons.

Sampford, M.R. (1967) On sampling without replacement with unequal probabilities of selection, Biometrika 54:499-513.

See Also

sampfle

Examples

library(sampfling)
samprop(10, 3, 1:10)
samprop(c("a","b","c"), 2, c(0.3,0.3,0.4))

[Package sampfling version 0.6-3 Index]