samprop {sampfling} | R Documentation |
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.
samprop(x, size, prob = NULL)
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. |
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.
A vector of size size
, which contains the sampled units from
x
, or indices if x
is an integer.
Carlos Enrique Carleos Artime carleos@vodafone.es.
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.
library(sampfling) samprop(10, 3, 1:10) samprop(c("a","b","c"), 2, c(0.3,0.3,0.4))