View source: R/weighting_plot.R
weighting_plot | R Documentation |
Propensity score weighting plot
weighting_plot(
ps,
treatment,
outcome,
estimand = "ATE",
null_hypothesis = 0,
method = "loess",
se = TRUE,
level = 0.95,
colors = c("#fc8d62", "#66c2a5"),
point_size_range = c(1, 8),
xlab = "Propensity Score",
ylab = "Outcome",
treat_lab = "Treatment",
size_lab = "PS Weight",
plot_points = TRUE
)
ps |
vector of propensity scores. |
treatment |
vector of treatment indicators. |
outcome |
vector of outcome values. |
estimand |
the estimand to use, either ATE, ATT, ATC, or ATM. |
null_hypothesis |
the value of the null hypothesis (typically zero). A horizontal line will be drawn to compare with regression line. |
method |
the method to use for the regression line. Typically loess, gan, or lm. |
se |
Display confidence interval around smooth? (TRUE by default, see level to control.) |
level |
Level of confidence interval to use (0.95 by default). |
colors |
vector of colors to use for control and treatment, respectively. |
point_size_range |
range of the point sizes. Needs to be a vector of length two. |
xlab |
label for the x-axis. |
ylab |
label for the y-axis. |
treat_lab |
label for the legend of group colors. |
size_lab |
label for the legend of point sizes. |
plot_points |
whether to plot the individual points. |
a ggplot2 expression.
if(require(Matching)) {
data(lalonde, package = 'Matching')
lr_out <- glm(treat ~ age + I(age^2) + educ + I(educ^2) + black +
hisp + married + nodegr + re74 + I(re74^2) + re75 + I(re75^2) +
u74 + u75,
data = lalonde,
family = binomial(link = 'logit'))
lalonde$ps <- fitted(lr_out)
weighting_plot(ps = lalonde$ps,
treatment = lalonde$treat,
outcome = log(lalonde$re78))
}
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.