Skip to contents

Normalise weights so they sum to n (sample) or N (population).

Usage

morie_weights_normalize(
  weights,
  target = c("sample_size", "population"),
  population_size = NULL
)

Arguments

weights

Numeric vector of unit-level design weights.

target

Numeric target sum (normalize).

population_size

Optional known population size used by normalize (target sum = population_size when supplied).

Value

A logical scalar.

Examples

set.seed(1)
res <- morie_weights_normalize(runif(30, 0.5, 2))
str(res, max.level = 1)
#>  num [1:30] 0.71 0.837 1.075 1.473 0.635 ...