Draws n units with replacement, with selection probability proportional to a size measure. A unit can be selected multiple times.

up_multinomial(x, n)

Arguments

x

A numeric vector of positive size measures (e.g., population, revenue, area). Must be non-negative.

n

The number of draws (sample size).

Value

An integer vector of n selected indices (1 to length(x)). May contain repeated values.

Details

Multinomial sampling (PPS with replacement) makes n independent draws, each with probability proportional to pik. This is equivalent to sampling::UPmultinomial() but returns indices instead of counts.

Properties:

  • Fixed number of draws n

  • Units can be selected multiple times

  • Selection probability per draw: \(p_k = x_k / \sum x_k\)

Useful for Hansen-Hurwitz estimation and bootstrap procedures.

See also

up_brewer(), up_maxent() for without-replacement methods, srs() with replace = TRUE for equal probability

Examples

# Size measures
x <- c(10, 20, 30, 40)

set.seed(1234)
idx <- up_multinomial(x, n = 5)
idx  # 5 indices, may repeat
#> [1] 4 3 3 3 2

table(idx)  # Unit 4 likely appears most often
#> idx
#> 2 3 4 
#> 1 3 1 

# Use for selection from data frame
df <- data.frame(id = 1:4, size = x)
df[idx, ]  # 5 rows, some repeated
#>     id size
#> 4    4   40
#> 3    3   30
#> 3.1  3   30
#> 3.2  3   30
#> 2    2   20