View source: R/inclusion_prob.R
inclusion_prob | R Documentation |
Calculate stratified (first-order) inclusion probabilities.
inclusion_prob(x, n, strata = gl(1, length(x)), alpha = 0.001, cutoff = Inf)
x |
A positive and finite numeric vector of sizes for units in the population (e.g., revenue for drawing a sample of businesses). |
n |
A positive integer vector giving the sample size for each stratum,
ordered according to the levels of |
strata |
A factor, or something that can be coerced into one, giving the strata associated with units in the population. The default is to place all units into a single stratum. |
alpha |
A numeric vector with values between 0 and 1 for each stratum,
ordered according to the levels of |
cutoff |
A positive numeric vector of cutoffs for each stratum, ordered
according to the levels of |
Within a stratum, the inclusion probability for a unit is given by
\pi = nx / \sum x
. These values can be greater
than 1 in practice, and so they are constructed iteratively by taking units
with \pi \geq 1 - \alpha
(from largest to smallest)
and assigning these units an inclusion probability of 1, with the remaining
inclusion probabilities recalculated at each step. If \alpha > 0
, then
any ties among units with the same size are broken by their position.
A numeric vector of inclusion probabilities for each unit in the population.
sps()
for drawing a sequential Poisson sample.
# Make a population with units of different size
x <- c(1:10, 100)
# Use the inclusion probabilities to calculate the variance of the
# sample size for Poisson sampling
pi <- inclusion_prob(x, 5)
sum(pi * (1 - pi))
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.