plot.lmw | R Documentation |
Produces plots to diagnose properties of the weights, including their distribution, to what degree the distribution of covariates involves extrapolation in the weighted sample, and how much influence each unit has on the effect estimate.
## S3 method for class 'lmw'
plot(x, type = "weights", ...)
x |
an |
type |
the type of plot to display. Allowable options include
|
... |
further arguments passed to specific types of plots. When
Other arguments are passed to When
When
|
When type = "weights"
, plot.lmw()
produces a density plot of
the weights within each treatment group. By construction, these weights will
have a mean of 1. Some weights may be negative. The effective sample size
(ESS) and original sample size (N) will be displayed in the upper right
corner of the plot when ess = TRUE
.
When type = "extrapolation"
, plot.lmw()
produces a plot of the
distribution of weights and covariates for each treatment group. Each dot
represents a unit, with values arranged on the x-axis according to their
covariate value and the size of the dots corresponding to the magnitude of
the weight. Units with positive weights are displayed in black in the upper
portion of the plot, and units with negative weights are displayed in red in
the lower portion. Having many and large red points indicates a high degree
of extrapolation. All points are equally transparent, so darker regions
indicate multiple points with the same value. The vertical lines indicates
the weighted mean of the covariate in each group, and the X indicates the
mean of the covariate in the target sample as determined by the
estimand
argument in the original call to lmw()
. A large
discrepancy between the vertical lines and Xs indicates a lack of balance
between the treatment group and target sample. When estimand = "CATE"
in the original call to lmw()
, any variables supplied to variables
that were not given a target value will not have the target mean displayed.
When type = "influence"
, plot.lmw()
produces a plot of the
scaled sample influence curve (SIC) for each unit by index. It does so by
calling influence.lmw()
, which fits the outcome model to extract
residuals and compute the SIC as SIC = (N-1) * w * r / (1 - h)
, where
N
is the sample size, w
are the units' implied regression
weights, r
are the residuals, and h
are the hat values. SIC
values are scaled to have a maximum of 1. Higher values indicate greater
relative influence.
A plot is displayed, and x
is invisibly returned.
lmw()
, summary.lmw()
,
plot.summary.lmw()
data("lalonde")
# URI regression for ATT
lmw.out1 <- lmw(~ treat + age + education + race + married +
nodegree + re74 + re75, data = lalonde,
estimand = "ATT", method = "URI",
treat = "treat")
lmw.out1
# Distribution of weights
plot(lmw.out1, type = "weights")
# Extrapolation/representativeness for age and married
plot(lmw.out1, type = "extrapolation",
variables = ~age + married)
# Extrapolation/representativeness for race
plot(lmw.out1, type = "extrapolation",
variables = ~race)
# Influence for re78 outcome
plot(lmw.out1, type = "influence", outcome = "re78")
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.