weightthem: Weights Multiply Imputed Datasets

Description Usage Arguments Details Value Author(s) References See Also Examples

Description

weightthem() performs weighting in the supplied imputed datasets, given as mids or amelia objects, by running WeightIt::weightit() on each of the imputed datasets with the supplied arguments.

Usage

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

Arguments

formula

A formula of the form z ~ x1 + x2, where z is the exposure and x1 and x2 are the covariates to be balanced, which is passed directly to codeWeightIt::weightit() to specify the propensity score model or treatment and covariates to be used to estimate the weights. See weightit() for details.

datasets

The datasets containing the exposure and covariates mentioned 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() from the mice package or to amelia() 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

The approach used to combine information across imputed datasets. Currently, "within" (estimating weights within each imputed dataset) and "across" (estimating propensity scores within each dataset, averaging them across datasets, and computing a single set of weights to be applied to all datasets) approaches are available. The default is "within", which has been shown to have superior performance in most cases.

method

The method used to estimate weights. See weightit() for allowable options. Only methods that produce a propensity score ("ps", "gbm", "cbps", "super", and "bart") are compatible with the "across" approach). The default is "ps" propensity score weighting using logistic regression propensity scores.

...

Additional arguments to be passed to weightit(). see weightit() for more details.

Details

If an amelia object is supplied to datasets, it will first be transformed into a mids object for further use. weightthem() works by calling mice::complete() on the mids object to extract a complete dataset, and then calls WeightIt::weightit() on each one, storing the output of each weightit() call and the mids in the output. All arguments supplied to weightthem() except datasets and approach are passed directly to weightit(). With the across method, the estimated propensity scores are averaged across imputations and re-supplied to another set of calls to weightit().

Value

An object of the wimids (weighted multiply imputed datasets) class, which includes the supplied mids object (or an amelia object transformed into a mids object if supplied) and the output of the calls to weightit() on each imputed dataset.

Author(s)

Farhad Pishgar and Noah Greifer

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

matchthem

WeightIt::weightit

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#1

#Loading libraries
library(MatchThem)

#Loading the dataset
data(osteoarthritis)

#Multiply imputing the missing values
imputed.datasets <- mice::mice(osteoarthritis, m = 5)

#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")

#2

#Loading libraries
library(Amelia)
library(MatchThem)

#Loading the dataset
data(osteoarthritis)

#Multiply imputing the missing values
imputed.datasets <- amelia(osteoarthritis, m = 5, noms = c("SEX", "RAC", "SMK", "OSP", "KOA"))

#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")

MatchThem documentation built on March 31, 2021, 9:08 a.m.