get.w {cobalt} | R Documentation |
Extract Weights from Preprocessing Objects
Description
Extracts weights from the outputs of preprocessing functions.
Usage
get.w(x, ...)
## S3 method for class 'matchit'
get.w(x, ...)
## S3 method for class 'ps'
get.w(x, stop.method = NULL, estimand, s.weights = FALSE, ...)
## S3 method for class 'mnps'
get.w(x, stop.method = NULL, s.weights = FALSE, ...)
## S3 method for class 'ps.cont'
get.w(x, s.weights = FALSE, ...)
## S3 method for class 'iptw'
get.w(x, stop.method = NULL, s.weights = FALSE, ...)
## S3 method for class 'Match'
get.w(x, ...)
## S3 method for class 'CBPS'
get.w(x, estimand, ...)
## S3 method for class 'CBMSM'
get.w(x, ...)
## S3 method for class 'ebalance'
get.w(x, treat, ...)
## S3 method for class 'optmatch'
get.w(x, estimand, ...)
## S3 method for class 'cem.match'
get.w(x, estimand, ...)
## S3 method for class 'weightit'
get.w(x, s.weights = FALSE, ...)
## S3 method for class 'designmatch'
get.w(x, treat, estimand, ...)
## S3 method for class 'mimids'
get.w(x, ...)
## S3 method for class 'wimids'
get.w(x, ...)
## S3 method for class 'sbwcau'
get.w(x, ...)
Arguments
x |
output from the corresponding preprocessing packages. |
... |
arguments passed to other methods. |
stop.method |
the name of the stop method used in the original call to |
estimand |
if weights are computed using the propensity score (i.e., for the If weights are computed using subclasses/matching strata (i.e., for the |
s.weights |
whether the sampling weights included in the original call to the fitting function should be included in the weights. If |
treat |
a vector of treatment status for each unit. This is required for methods that include |
Details
The output of get.w()
can be used in calls to the formula and data frame methods of bal.tab()
(see example below). In this way, the output of multiple preprocessing packages can be viewed simultaneously and compared. The weights can also be used in weights
statements in regression methods to compute weighted effects.
twang has a function called get.weights()
that performs the same function on ps
objects but offers slightly finer control. Note that the weights generated by get.w()
for ps
objects do not include sampling weights by default.
When sampling weights are used with CBPS()
in CBPS, the returned weights will already have the sampling weights incorporated. To retrieve the balancing weights on their own, divide the returned weights by the original sampling weights. For other packages, the balancing weights are returned separately unless s.weights = TRUE
, which means they must be multiplied by the sampling weights for effect estimation.
When Match()
in Matching is used with CommonSupport = TRUE
, the returned weights will be incorrect. This option is not recommended by the package authors.
Value
A vector or data frame of weights for each unit. These may be matching weights or balancing weights.
Examples
data("lalonde", package = "cobalt")
m.out <- MatchIt::matchit(treat ~ age + educ + race,
data = lalonde,
estimand = "ATT")
w.out <- WeightIt::weightit(treat ~ age + educ + race,
data = lalonde,
estimand = "ATT")
bal.tab(treat ~ age + educ + race, data = lalonde,
weights = data.frame(matched = get.w(m.out),
weighted = get.w(w.out)),
method = c("matching", "weighting"),
estimand = "ATT")