Calibrate: 'Calibrate'

View source: R/calibrate.R

CalibrateR Documentation

Calibrate

Description

Creates a sampling weight based on raking/calibration. Raking is used if it can be used (i.e., no numeric adjustment variables and always.calibrate not FALSE)

Usage

Calibrate(
  categorical.variables = NULL,
  categorical.targets = NULL,
  numeric.variables = NULL,
  numeric.targets = NULL,
  lower = NA,
  upper = NA,
  trim.iterations = 20,
  package = c("CVXR", "survey", "icarus")[1],
  always.calibrate = FALSE,
  subset = NULL,
  input.weight = NULL
)

Arguments

categorical.variables

An optional list or data frame of categorical adjustment variables.

categorical.targets

The target probabilities for each category listed in categorical.variables

numeric.variables

An optional list or data frame of categorical adjustment variables.

numeric.targets

the target mean for each numeric variable in numeric.variables

lower

A lower bound weight value (not guaranteed to be achieved).

upper

An upper bound weight value (not guaranteed to be achieved).

trim.iterations

The number of times to run the trim loop over the final weightings

package

The R package used to calibrate the model when raking is not conducted. Defaults to CVXR (see https://cvxr.rbind.io/cvxr_examples/cvxr_survey_calibration/). Other options are icarus and survey. . Use icarus with care, as sometimes target categories can be switched around

always.calibrate

If FALSE, which is the default, problems with only categorical adjustment variables are solved via iterative-proportional fitting (raking). Otherwise, they are solved via calibration.

subset

A logical vector indicating which subset of cases should be used to create the weight

input.weight

An optional weight variable; if supplied, the created weight is created to be as close to this input.weight as possible

Value

numeric A vector of weights


Displayr/flipData documentation built on March 2, 2024, 3:49 a.m.