Skip to contents

These functions summarize the weights resulting from a call to optweight or optweight.svy. summary produces summary statistics on the distribution of weights, including their range and variability, and the effective sample size of the weighted sample (computing using the formula in McCaffrey, Rudgeway, & Morral, 2004). plot creates a histogram of the weights.

Usage

# S3 method for optweight
summary(object, top = 5, ignore.s.weights = FALSE, ...)

# S3 method for optweightMSM
summary(object, top = 5, ignore.s.weights = FALSE, ...)

# S3 method for optweight.svy
summary(object, top = 5, ignore.s.weights = FALSE, ...)

# S3 method for summary.optweight
print(x, ...)

# S3 method for summary.optweightMSM
print(x, ...)

# S3 method for summary.optweight.svy
print(x, ...)

# S3 method for summary.optweight
plot(x, ...)

Arguments

object

An optweight, optweightMSM, or optweight.svy object; the output of a call to optweight or optweight.svy.

top

How many of the largest and smallest weights to display. Default is 5.

ignore.s.weights

Whether or not to ignore sampling weights when computing the weight summary. If FALSE, the default, the estimated weights will be multiplied by the sampling weights (if any) before values are computed.

x

A summary.optweight, summary.optweightMSM, or summary.optweight.svy object; the output of a call to summary.optweight, summary.optweightMSM, or summary.optweight.svy.

...

Additional arguments. For plot, additional arguments passed to hist to determine the number of bins, though geom_histogram from ggplot2 is actually used to create the plot.

Value

For point treatments (i.e., optweight objects), summary returns a summary.optweight object with the following elements:

weight.range

The range (minimum and maximum) weight for each treatment group.

weight.top

The units with the greatest weights in each treatment group; how many are included is determined by top.

coef.of.var

The coefficient of variation (standard deviation divided by mean) of the weights in each treatment group and overall. When no sampling weights are used, this is simply the standard deviation of the weights.

mean.abs.dev

The mean absolute deviation of the weights in each treatment group and overall.

effective.sample.size

The effective sample size for each treatment group before and after weighting.

For longitudinal treatments (i.e., optweightMSM objects), a list of the above elements for each treatment period.

For optweight.svy objects, a list of the above elements but with no treatment group divisions.

plot returns a ggplot object with a histogram displaying the distribution of the estimated weights. If the estimand is the ATT or ATC, only the weights for the non-focal group(s) will be displayed (since the weights for the focal group are all 1). A dotted line is displayed at the mean of the weights (usually 1).

References

McCaffrey, D. F., Ridgeway, G., & Morral, A. R. (2004). Propensity Score Estimation With Boosted Regression for Evaluating Causal Effects in Observational Studies. Psychological Methods, 9(4), 403–425. doi:10.1037/1082-989X.9.4.403

Author

Noah Greifer

See also

plot.optweight for plotting the values of the dual variables.

Examples

library("cobalt")
data("lalonde", package = "cobalt")

#Balancing covariates between treatment groups (binary)
(ow1 <- optweight(treat ~ age + educ + married +
                nodegree + re74, data = lalonde,
                tols = .001,
                estimand = "ATT"))
#> An optweight object
#>  - number of obs.: 614
#>  - sampling weights: none
#>  - treatment: 2-category
#>  - estimand: ATT (focal: 1)
#>  - covariates: age, educ, married, nodegree, re74

(s <- summary(ow1))
#> Summary of weights:
#> 
#> - Weight ranges:
#>         Min                                  Max
#> treated   1           ||                  1.0000
#> control   0 |---------------------------| 3.0186
#> 
#> - Units with 5 greatest weights by group:
#>                                            
#>               2      3      4      5      1
#>  treated      1      1      1      1      1
#>             589    411    409    296    269
#>  control 2.5106 2.5273 2.6258 2.7208 3.0186
#> 
#>         Coef of Var Mean Abs Dev
#> treated      0.0000       0.0000
#> control      0.7833       0.6940
#> overall      0.6547       0.4849
#> 
#> - Effective Sample Sizes:
#>            Control Treated
#> Unweighted 429.000     185
#> Weighted   265.882     185

plot(s, breaks = 12)