Skip to contents

Closed-form linear calibration to match population totals on auxiliary X. When survey is installed, defers to survey::calibrate() for a fully design-aware result; otherwise computes the linear adjustment in base R.

Usage

morie_weights_greg(weights, X, population_totals, max_iter = 50, tol = 1e-08)

Arguments

weights

Numeric vector of unit-level design weights.

X

A numeric matrix or data.frame of 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.

Value

A named list with elements weights, converged, iterations, max_adjustment, diagnostics.

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    : num 1
#>  $ max_adjustment: num 7.11e-15
#>  $ diagnostics   :List of 14