View source: R/get_w_from_ps.R
get_w_from_ps | R Documentation |
Given a vector or matrix of propensity scores, outputs a vector of weights that target the provided estimand.
get_w_from_ps(
ps,
treat,
estimand = "ATE",
focal = NULL,
treated = NULL,
subclass = NULL,
stabilize = FALSE
)
ps |
a vector, matrix, or data frame of propensity scores. See Details. |
treat |
a vector of treatment status for each individual. See Details. |
estimand |
the desired estimand that the weights should target. Current
options include |
focal |
when |
treated |
when treatment is binary, the value of |
subclass |
|
stabilize |
|
get_w_from_ps()
applies the formula for computing weights from
propensity scores for the desired estimand. The formula for each estimand is below, with A_i
the treatment value for unit i
taking on values \mathcal{A} = (1, \ldots, g)
, p_{a, i}
the probability of receiving treatment level a
for unit i
, and f
is the focal group (the treated group for the ATT and the control group for the ATC):
\begin{aligned}
w^{ATE}_i &= 1 / p_{A_i, i} \\
w^{ATT}_i &= w^{ATE}_i \times p_{f, i} \\
w^{ATO}_i &= w^{ATE}_i / \sum_{a \in \mathcal{A}}{1/p_{a, i}} \\
w^{ATM}_i &= w^{ATE}_i \times \min(p_{1, i}, \ldots, p_{g, i}) \\
w^{ATOS}_i &= w^{ATE}_i \times \mathbb{1}\left(\alpha < p_{2, i} < 1 - \alpha\right)
\end{aligned}
get_w_from_ps()
can only be used with binary and multi-category treatments.
ps
argumentThe ps
argument can be entered in two ways:
A numeric matrix with a row for each unit and a (named) column for each treatment level, with each cell corresponding to the probability of receiving the corresponding treatment level
A numeric vector with a value for each unit corresponding to the probability of being "treated" (only allowed for binary treatments)
When supplied as a vector, get_w_from_ps()
has to know which value of treat
corresponds to the "treated" group. For 0/1 variables, 1 will be considered
treated. For other types of variables, get_w_from_ps()
will try to
figure it out using heuristics, but it's safer to supply an argument to
treated
. When estimand
is "ATT"
or "ATC"
, supplying a value to
focal
is sufficient (for ATT, focal
is the treated group, and
for ATC, focal
is the control group).
When supplied as a matrix, the columns must be named with the levels of the treatment, and
it is assumed that each column corresponds to the probability of being in
that treatment group. This is the safest way to supply ps
unless
treat
is a 0/1 variable. When estimand
is "ATT"
or "ATC"
, a value for focal
must be specified.
When subclass
is not NULL
, MMWS weights are computed. The implementation differs
slightly from that described in Hong (2010, 2012). First, subclasses are
formed by finding the quantiles of the propensity scores in the target group
(for the ATE, all units; for the ATT or ATC, just the units in the focal
group). Any subclasses lacking members of a treatment group will be filled
in with them from neighboring subclasses so each subclass will always have
at least one member of each treatment group. A new subclass-propensity score
matrix is formed, where each unit's subclass-propensity score for each
treatment value is computed as the proportion of units with that treatment
value in the unit's subclass. For example, if a subclass had 10 treated
units and 90 control units in it, the subclass-propensity score for being
treated would be .1 and the subclass-propensity score for being control
would be .9 for all units in the subclass.
For multi-category treatments, the propensity scores for each treatment are stratified separately as described in Hong (2012); for binary treatments, only one set of propensity scores are stratified and the subclass-propensity scores for the other treatment are computed as the complement of the propensity scores for the stratified treatment.
After the subclass-propensity scores have been
computed, the standard propensity score weighting formulas are used to
compute the unstabilized MMWS weights. To estimate MMWS weights equivalent
to those described in Hong (2010, 2012), stabilize
must be set to
TRUE
, but, as with standard propensity score weights, this is
optional. Note that MMWS weights are also known as fine stratification
weights and described by Desai et al. (2017).
A vector of weights. When subclass
is not NULL
, the
subclasses are returned as the "subclass"
attribute. When
estimand = "ATOS"
, the chosen value of alpha
(the smallest
propensity score allowed to remain in the sample) is returned in the
"alpha"
attribute.
estimand = "ATO"
Li, F., Morgan, K. L., & Zaslavsky, A. M. (2018). Balancing covariates via propensity score weighting. Journal of the American Statistical Association, 113(521), 390–400. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/01621459.2016.1260466")}
estimand = "ATM"
Li, L., & Greene, T. (2013). A Weighting Analogue to Pair Matching in Propensity Score Analysis. The International Journal of Biostatistics, 9(2). \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1515/ijb-2012-0030")}
estimand = "ATOS"
Crump, R. K., Hotz, V. J., Imbens, G. W., & Mitnik, O. A. (2009). Dealing with limited overlap in estimation of average treatment effects. Biometrika, 96(1), 187–199. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1093/biomet/asn055")}
Other estimands
Austin, P. C. (2011). An Introduction to Propensity Score Methods for Reducing the Effects of Confounding in Observational Studies. Multivariate Behavioral Research, 46(3), 399–424. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1080/00273171.2011.568786")}
Marginal mean weighting through stratification (MMWS)
Hong, G. (2010). Marginal mean weighting through stratification: Adjustment for selection bias in multilevel data. Journal of Educational and Behavioral Statistics, 35(5), 499–531. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.3102/1076998609359785")}
Desai, R. J., Rothman, K. J., Bateman, B. . T., Hernandez-Diaz, S., & Huybrechts, K. F. (2017). A Propensity-score-based Fine Stratification Approach for Confounding Adjustment When Exposure Is Infrequent: Epidemiology, 28(2), 249–257. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1097/EDE.0000000000000595")}
estimand = "ATO"
Li, F., & Li, F. (2019). Propensity score weighting for causal inference with multiple treatments. The Annals of Applied Statistics, 13(4), 2389–2415. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1214/19-AOAS1282")}
estimand = "ATM"
Yoshida, K., Hernández-Díaz, S., Solomon, D. H., Jackson, J. W., Gagne, J. J., Glynn, R. J., & Franklin, J. M. (2017). Matching weights to simultaneously compare three treatment groups: Comparison to three-way matching. Epidemiology (Cambridge, Mass.), 28(3), 387–395. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1097/EDE.0000000000000627")}
Other estimands
McCaffrey, D. F., Griffin, B. A., Almirall, D., Slaughter, M. E., Ramchand, R., & Burgette, L. F. (2013). A Tutorial on Propensity Score Estimation for Multiple Treatments Using Generalized Boosted Models. Statistics in Medicine, 32(19), 3388–3414. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1002/sim.5753")}
Marginal mean weighting through stratification
Hong, G. (2012). Marginal mean weighting through stratification: A generalized method for evaluating multivalued and multiple treatments with nonexperimental data. Psychological Methods, 17(1), 44–60. \Sexpr[results=rd]{tools:::Rd_expr_doi("10.1037/a0024918")}
method_glm
library("cobalt")
data("lalonde", package = "cobalt")
ps.fit <- glm(treat ~ age + educ + race + married +
nodegree + re74 + re75, data = lalonde,
family = binomial)
ps <- ps.fit$fitted.values
w1 <- get_w_from_ps(ps, treat = lalonde$treat,
estimand = "ATT")
treatAB <- factor(ifelse(lalonde$treat == 1, "A", "B"))
w2 <- get_w_from_ps(ps, treat = treatAB,
estimand = "ATT", focal = "A")
all.equal(w1, w2)
w3 <- get_w_from_ps(ps, treat = treatAB,
estimand = "ATT", treated = "A")
all.equal(w1, w3)
# Using MMWS
w4 <- get_w_from_ps(ps, treat = lalonde$treat,
estimand = "ATE", subclass = 20,
stabilize = TRUE)
# A multi-category example using predicted probabilities
# from multinomial logistic regression
T3 <- factor(sample(c("A", "B", "C"), nrow(lalonde),
replace = TRUE))
multi.fit <- multinom_weightit(
T3 ~ age + educ + race + married +
nodegree + re74 + re75, data = lalonde,
vcov = "none"
)
ps.multi <- fitted(multi.fit)
head(ps.multi)
w5 <- get_w_from_ps(ps.multi, treat = T3,
estimand = "ATE")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.