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.
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.