plot.lmw {lmw}R Documentation

Plots diagnosing regression-implied weights

Description

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.

Usage

## S3 method for class 'lmw'
plot(x, type = "weights", ...)

Arguments

x

an lmw object; the output of a call to lmw().

type

the type of plot to display. Allowable options include "weights", "extrapolation", and "influence". See Details. Abbreviations allowed.

...

further arguments passed to specific types of plots.

When type = "weights", the following are accepted:

rug

logical; whether to display a rug plot of the weights. Default is TRUE.

mean

whether to display a red line indicating the mean of the weights. Default is TRUE.

ess

whether to display the original and weighted effective sample size in the top right corner. Default is TRUE.

Other arguments are passed to density().

When type = "extrapolation", the following are accepted:

variables

required; a right-sided formula or character vector containing the names of the covariates for which extrapolation is to be assessed.

data

an optional data frame containing the variables named in variables.

When type = "influence", the following are accepted:

outcome

the name of the outcome variable. Can be supplied as a string containing the name of the outcome variable or as the outcome variable itself. If not supplied, the outcome variable in the formula supplied to lmw(), if any, will be used.

data

an optional data frame containing the outcome variable named in outcome.

id.n

the number of points to be labelled in the plot, starting with the most extreme.

Details

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.

Value

A plot is displayed, and x is invisibly returned.

See Also

lmw(), summary.lmw(), plot.summary.lmw()

Examples

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

[Package lmw version 0.0.2 Index]