multical: Calibrate sample to target via multilevel calibration

Description Usage Arguments Value

View source: R/multical.R

Description

Finds weights that exactly calibrate first order margins between respondents and the target population. Requires individual-level of cell-level data.

Usage

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
multical(
  formula,
  target_count,
  data,
  order = NULL,
  lambda = NULL,
  lambda_max = NULL,
  n_lambda = 20,
  lambda_min_ratio = 1e-05,
  lowlim = 0,
  uplim = Inf,
  verbose = FALSE,
  ...
)

Arguments

formula

Formula of the form sample_count ~ covariates, where sample_count is whether or not an individual responded (with individual-level data) or the number of respondents in the cell (with cell-level data) and covariates are the covariates to calibrate on

target_count

Name of column with indicators for whether an individual is in the target population (with individual-level data) or the target counts for each cell (with cell-level data)

data

Dataframe with covariate information, sample and target counts

order

Integer. What order interactions to balance. Default is all orders

lambda

Numeric. Regularization hyperparamter, by default fits weights for a range of values

lambda_max

Numeric. Maximum hyperparameter to fit weights with, default is the root sum of squared differences between the (unweighted) sample and the target

n_lambda

Integer. Number of hyper-parameters to fit weights for, from lambda_max to lambda_max * lambda_min_ratio, equally spaced on the log scale. Default, 20

lambda_min_ratio

Numeric. Ratio of min to max lambda to consider.

lowlim

Lower bound on weights, default 0

uplim

Upper bound on weights, default Inf

verbose

Boolean. Show optimization information, default False

...

Additional parameters for osqp

Value

data frame with the weight for each distinct cell, for each value of the hyperparameter lambda. Note: the output data frame may have the cells in a different order than in data. Be sure to join the output with data on the variables to map the weights to the data accurately.


ebenmichael/multical documentation built on Dec. 20, 2021, 3:12 a.m.