This functions is essentially a wrapper around the weightit function. The user can specify the method to be used to estimate the weights.

estimate_weights(
  dat,
  exposure,
  covariates,
  s.weights,
  id_var,
  method,
  method_args
)

Arguments

dat

A dataframe containing the variables of interest. A dataframe.

exposure

The name of the variable corresponding to the exposure. A string.

covariates

A vector of covariates' names. A vector.

s.weights

Sampling weights. A vector.

id_var

The variable name to be used to identify subjects. A string.

method

The method to be used by weightit to estimate the weights. A string.

method_args

A named list with the following variables:

  • stabilize, whether to stabilize the weights or not.

  • by, a string containing the name of the variable for which weighting is to be done within categories.

  • sl_lib, either a vector of learners or FALSE, in which case it uses a fixed library of learners.

  • sl_discrete, whether to use discrete SuperLearner, which selects the best performing method, or to find the optimal combination of predictions.

  • use_kernel, whether to use kernel density estimation to estimate the numerator and denominator densities for the weights. A logical.

  • family_link, family to be used within the fitted model.

Value

A named list containing the estimated weights, and the names of the exposure and covariates used.