Skip to contents

For multi-variable marginals use morie_weights_rake(); this helper is the single-variable convenience.

Usage

morie_survey_calibrate(
  df,
  aux_vars,
  population_totals,
  max_iter = 50,
  tol = 1e-06
)

Arguments

df

A data.frame holding the (unit-level) sample data plus any weight/strata/cluster/domain columns referenced by name.

aux_vars

Character vector of column names of auxiliary variables used for calibration (raking, GREG, etc.).

population_totals

Named numeric vector of population totals to calibrate to (one entry per aux_vars element).

max_iter

Iteration cap for the iterative calibration loop.

tol

Convergence tolerance for calibration.

Value

A numeric vector of calibration weights.

Examples

set.seed(1)
df <- data.frame(x1 = runif(30, 1, 3))
res <- morie_survey_calibrate(df, "x1", c(x1 = 60))
str(res, max.level = 1)
#>  num [1:30] 0.991 0.991 0.991 0.991 0.991 ...