Skip to contents

Adjusts weights so that within each calibration variable the weighted sums match the supplied marginal targets. margins is a named list keyed by variable name; each entry is a named numeric vector mapping category values (as strings) to target totals.

Usage

morie_weights_rake(
  weights,
  df,
  margins,
  max_iter = 100,
  tol = 1e-06,
  bounds = NULL
)

Arguments

weights

Initial numeric weights (length n).

df

data.frame containing the calibration variables.

margins

Named list of named numeric vectors.

max_iter

Maximum IPF iterations (default 100).

tol

Convergence tolerance on max relative adjustment (default 1e-6).

bounds

Optional c(lo, hi) to clip the per-iteration multiplier.

Value

list with weights, converged, iterations, max_adjustment, diagnostics (from morie_weights_diagnostics).