Skip to contents

Compute inclusion probabilities from a size measure, or extract them from a without-replacement design object.

Usage

inclusion_prob(x, ...)

# S3 method for class 'wor'
inclusion_prob(x, ...)

# S3 method for class 'wr'
inclusion_prob(x, ...)

# Default S3 method
inclusion_prob(x, n, ...)

Arguments

x

A numeric vector of positive size measures, or a without-replacement design object (class "wor").

...

Additional arguments (currently unused).

n

The desired sample size. Required when x is a numeric vector, ignored when x is a design object.

Value

A numeric vector of inclusion probabilities. When applied to a design object, returns the stored pik vector. For most methods this equals the true first-order inclusion probabilities. For order-sampling methods (sps, pareto), it is the target used to define the design; the true probabilities are approximately equal and converge as N grows.

Details

When x is a numeric vector and n is provided, computes inclusion probabilities via iterative capping: units with \(\pi_k \ge 1\) are set to 1 (certainty selections) and the remaining probabilities are recomputed with reduced \(n\). The result sums to exactly \(n\). This differs from expected_hits(), which does simple proportional allocation without capping. Negative values in x are treated as zero (with a warning).

See also

expected_hits() for the with-replacement analogue, unequal_prob_wor() for sampling with these probabilities.

Examples

# From size measures
size <- c(10, 20, 30, 40)
pik <- inclusion_prob(size, n = 2)
sum(pik)  # 2
#> [1] 2

# From a design object
s <- unequal_prob_wor(pik, method = "cps")
inclusion_prob(s)
#> [1] 0.2 0.4 0.6 0.8

# With certainty selections (large units)
size <- c(1, 1, 1, 100)
pik <- inclusion_prob(size, n = 2)
pik  # Unit 4 gets probability 1
#> [1] 0.3333333 0.3333333 0.3333333 1.0000000