Linear (chi-square distance) calibration to match population totals on
auxiliary X, computed natively in base R: \(w^* = w(1 + x^\top
\lambda)\) with \(\lambda = (X^\top W X)^{-1}(T_x - \hat T_x)\), the
step repeated on the calibrated weights until the totals match within
tol (the linear calibration of survey::calibrate(); no package is
called).
Arguments
- weights
Numeric vector of unit-level design weights.
- X
A numeric matrix or
data.frameof auxiliary variables (one row per unit) used by GREG / nonresponse propensity models.- population_totals
Named numeric vector of target totals to calibrate to.
- max_iter
Iteration cap for calibration / IPF.
- tol
Convergence tolerance for calibration.
Examples
set.seed(1)
X <- cbind(intercept = 1, x = runif(30))
res <- morie_weights_greg(rep(1, 30), X, c(intercept = 35, x = 18))
str(res, max.level = 1)
#> List of 5
#> $ weights : num [1:30] 1.15 1.16 1.17 1.19 1.15 ...
#> $ converged : logi TRUE
#> $ iterations : int 1
#> $ max_adjustment: num 7.11e-15
#> $ diagnostics :List of 14
