Learn R Programming

MatchThem (version 0.9.0)

weightthem: Weights Multiply Imputed Datasets

Description

weightthem() function enables parametric models for causal inference to work better by estimating weights of the control and treated units in each imputed dataset of a mids or amelia class object.

Usage

weightthem(formula, datasets, approach = "within", method = "ps",
  estimand = "ATE", ...)

Arguments

formula

This argument takes the usual syntax of R formula, z ~ x1 + x2, where z is a binary exposure indicator and x1 and x2 are the potential confounders. Both the exposure indicator and the potential confounders must be contained in the imputed datasets, which is specified as datasets (see below). All of the usual R syntax for formula works. For example, x1:x2 represents the first order interaction term between x1 and x2 and I(x1^2) represents the square term of x1. See help(formula) for details.

datasets

This argument specifies the datasets containing the exposure indicator and the potential confounders called in the formula. This argument must be an object of the mids or amelia class, which is typically produced by a previous call to mice() or mice.mids() functions from the mice package or to amelia() function from the Amelia package (the Amelia package is designed to impute missing data in a single cross-sectional dataset or in a time-series dataset, currently, the MatchThem package only supports the former datasets).

approach

This argument specifies a matching approach. Currently, "within" (calculating distance measures within each imputed dataset and weighting observations based on them ) and "across" (calculating distance measures within each imputed dataset, averaging distance measure for each observation across imputed datasets, and weighting based on the averaged measures) approaches are available. The default is "within" which has been shown to produce unbiased results.

method

This argument specifies the method that should be used to estimate weights. Currently, "ps" (propensity score weighting using generalized linear models), "gbm" (propensity score weighting using generalized boosted modeling), "cbps" (covariate balancing propensity score weighting), "npcbps" (non-parametric covariate balancing propensity score weighting), "ebal" (entropy balancing), "ebcw" (empirical balancing calibration weighting), "optweight" (optimization-based weighting), "super" (propensity score weighting using SuperLearner), and "user-defined" (weighting using a user-defined weighting function) are available (only the "ps", "gbm", "cbps", and "super" weighting methods are compatible with the "across" approach). The default is "ps". Note that within each of these weighting methods, MatchThem offers a variety of options.

estimand

This argument specifies the desired estimand. For binary and multinomial treatments, can be "ATE", "ATT", "ATC", and, for some weighting methods, "ATO" or "ATM". The default is "ATE". Please see the WeightIt package reference manual <https://cran.r-project.org/package=WeightIt> for more details.

...

Additional arguments to be passed to the weighting method (please see the WeightIt package reference manual <https://cran.r-project.org/package=WeightIt> for more details).

Value

This function returns an object of the wimids (weighted multiply imputed datasets) class, that includes weights of observations of the imputed datasets (listed as the weights variables in each) primarily passed to the function by the datasets argument.

Details

The weighting is done using the weightthem(z ~ x1, ...) command, where z is the exposure indicator and x1 represents the potential confunders to be used in the weighting model. The default syntax is weightthem(formula, datasets, approach = "within", method = "ps", estimand = "ATE", ...). Summaries of the results can be seen numerically using summary() function. The print() function also prints out the output.

References

Stef van Buuren and Karin Groothuis-Oudshoorn (2011). mice: Multivariate Imputation by Chained Equations in R. Journal of Statistical Software, 45(3): 1-67. https://www.jstatsoft.org/v45/i03/

See Also

wimids

with

pool

Examples

Run this code
# NOT RUN {
#Loading the dataset
data(osteoarthritis)

#Multiply imputing the missing values
imputed.datasets <- mice(osteoarthritis, m = 5, maxit = 10,
                         method = c("", "", "mean", "polyreg",
                                    "logreg", "logreg", "logreg"))

#Estimating weights of observations in the multiply imputed datasets
weighted.datasets <- weightthem(OSP ~ AGE + SEX + BMI + RAC + SMK, imputed.datasets,
                                approach = 'within', method = 'ps', estimand = "ATT")
# }

Run the code above in your browser using DataLab