do_rake: Performs iterative raking on data

View source: R/rake.R

do_rakeR Documentation

Performs iterative raking on data

Description

This function performs iterative raking as described in DeBell and Krosnick (2009). It is a private function and not intended for end-users. End-users should call harvest to add weights.

Usage

do_rake(data, target, weights, max_weight, max_iterations, convergence,
  enforce_mean = TRUE, verbose)

Arguments

data

The data frame (tibble) or matrix containing the original data

target

The target proportions, specified as in harvest

weights

A numeric vector of current weights

max_weight

The maximum weight to clamp weights to after raking each variable

max_iterations

The maximum number of iterations of raking to perform before giving up. Please note that depending on the variable selection method, harvest may continue iterative raking on new variables after completing the iterations of this function call.

convergence

Convergence parameters as described in harvest.

enforce_mean

Default TRUE. By default, weights minimize divergence from target proportions subject to two conditions: that the mean weight be 1, and that the maximum weight be capped at max_weight. Weights are first capped and then re-meaned. When enforce_mean is FALSE, the re-meaning does not occur. This will guarantee the maximum weight does not exceed max_weight but may result in mean weights diverging from 1. As max_weight prevents high-weight observations from becoming higher weighted, enforce_mean helps low-weight observations from becoming even lower weighted.

verbose

Level of verbosity, defaults to FALSE. At TRUE or 1, the function begins emitting progress information during major events. At 2, each iteration provides progress information.

Value

A numeric vector of adjusted, raked weights.


aaronrudkin/autumn documentation built on Feb. 5, 2024, 6:08 p.m.