# Make inclusion probabilities for a population with units
# of different size
x <- c(1:10, 100)
(pi <- inclusion_prob(x, 5))
# The last unit is sufficiently large to be included in all
# samples with two or more units
becomes_ta(x)
# Determine the number of take-all units before drawing a sample
n_ta <- function(x, n, ...) {
sum(becomes_ta(x, ...) <= n, na.rm = TRUE)
}
n_ta(x, 7)
# Use the inclusion probabilities to calculate the variance of the
# sample size for Poisson sampling
sum(pi * (1 - pi))
Run the code above in your browser using DataLab