WeightIt
Objectsbal.tab.weightit.Rd
Generates balance statistics for weightit
and weightitMSM
objects from WeightIt.
# S3 method for weightit
bal.tab(x,
stats,
int = FALSE,
poly = 1,
distance = NULL,
addl = NULL,
data = NULL,
continuous,
binary,
s.d.denom,
thresholds = NULL,
weights = NULL,
cluster = NULL,
imp = NULL,
pairwise = TRUE,
s.weights = NULL,
abs = FALSE,
subset = NULL,
quick = TRUE,
...)
a weightit
or weightitMSM
object; the output of a call to WeightIt::weightit()
or WeightIt::weightitMSM()
.
see bal.tab()
for details.
See below for special notes on the distance
, s.d.denom
, and s.weights
arguments.
The following arguments have special notes when used with weightit
and weightitMSM
objects:
propensity scores generated by weightit()
and weightitMSM()
are automatically included and named "prop.score".
if not specified, bal.tab()
will figure out which one is best based on the estimand of the weightit
object: if ATT, "treated"
; if ATC, "control"
; otherwise "pooled"
. Abbreviations allowed.
if s.weights
was supplied in the call to weightit()
or weightitMSM()
, they will automatically be included and do not need be specified again (though there is no harm if they are).
bal.tab.weightit()
generates a list of balance summaries for the weightit
object given.
For point treatments, if clusters and imputations are not specified, an object of class "bal.tab"
containing balance summaries for the weightit
object. See bal.tab()
for details.
If imputations are specified, an object of class "bal.tab.imp"
containing balance summaries for each imputation and a summary of balance across imputations. See bal.tab.imp
for details.
If weightit()
is used with multi-category treatments, an object of class "bal.tab.multi"
containing balance summaries for each pairwise treatment comparison. See bal.tab.multi
for details.
If weightitMSM()
is used for longitudinal treatments, an object of class "bal.tab.msm"
containing balance summaries for each time period. See bal.tab.msm
for details.
If clusters are specified, an object of class "bal.tab.cluster"
containing balance summaries within each cluster and a summary of balance across clusters. See bal.tab.cluster
for details.
bal.tab()
for details of calculations.
library(WeightIt)
data("lalonde", package = "cobalt")
## Basic propensity score weighting
w.out1 <- weightit(treat ~ age + educ + race +
married + nodegree + re74 + re75,
data = lalonde, method = "ps")
bal.tab(w.out1, un = TRUE, m.threshold = .1,
v.threshold = 2)
#> Call
#> weightit(formula = treat ~ age + educ + race + married + nodegree +
#> re74 + re75, data = lalonde, method = "ps")
#>
#> Balance Measures
#> Type Diff.Un V.Ratio.Un Diff.Adj M.Threshold V.Ratio.Adj
#> prop.score Distance 1.7569 0.9211 0.1360 0.9758
#> age Contin. -0.2419 0.4400 -0.1676 Not Balanced, >0.1 0.3689
#> educ Contin. 0.0448 0.4959 0.1296 Not Balanced, >0.1 0.5657
#> race_black Binary 0.6404 . 0.0499 Balanced, <0.1 .
#> race_hispan Binary -0.0827 . 0.0047 Balanced, <0.1 .
#> race_white Binary -0.5577 . -0.0546 Balanced, <0.1 .
#> married Binary -0.3236 . -0.0944 Balanced, <0.1 .
#> nodegree Binary 0.1114 . -0.0547 Balanced, <0.1 .
#> re74 Contin. -0.5958 0.5181 -0.2740 Not Balanced, >0.1 0.8208
#> re75 Contin. -0.2870 0.9563 -0.1579 Not Balanced, >0.1 0.9562
#> V.Threshold
#> prop.score Balanced, <2
#> age Not Balanced, >2
#> educ Balanced, <2
#> race_black
#> race_hispan
#> race_white
#> married
#> nodegree
#> re74 Balanced, <2
#> re75 Balanced, <2
#>
#> Balance tally for mean differences
#> count
#> Balanced, <0.1 5
#> Not Balanced, >0.1 4
#>
#> Variable with the greatest mean difference
#> Variable Diff.Adj M.Threshold
#> re74 -0.274 Not Balanced, >0.1
#>
#> Balance tally for variance ratios
#> count
#> Balanced, <2 4
#> Not Balanced, >2 1
#>
#> Variable with the greatest variance ratio
#> Variable V.Ratio.Adj V.Threshold
#> age 0.3689 Not Balanced, >2
#>
#> Effective sample sizes
#> Control Treated
#> Unadjusted 429. 185.
#> Adjusted 329.01 58.33
## Weighting with a multi-category treatment
w.out2 <- weightit(race ~ age + educ + married +
nodegree + re74 + re75,
data = lalonde, method = "ps",
estimand = "ATE", use.mlogit = FALSE)
bal.tab(w.out2, un = TRUE)
#> Call
#> weightit(formula = race ~ age + educ + married + nodegree + re74 +
#> re75, data = lalonde, method = "ps", estimand = "ATE", use.mlogit = FALSE)
#>
#> Balance summary across all treatment pairs
#> Type Max.Diff.Un Max.Diff.Adj
#> age Contin. 0.3065 0.0504
#> educ Contin. 0.5861 0.1046
#> married Binary 0.3430 0.0355
#> nodegree Binary 0.2187 0.0438
#> re74 Contin. 0.6196 0.1445
#> re75 Contin. 0.3442 0.1462
#>
#> Effective sample sizes
#> black hispan white
#> Unadjusted 243. 72. 299.
#> Adjusted 140.5 54.32 259.28
bal.tab(w.out2, un = TRUE, pairwise = FALSE)
#> Call
#> weightit(formula = race ~ age + educ + married + nodegree + re74 +
#> re75, data = lalonde, method = "ps", estimand = "ATE", use.mlogit = FALSE)
#>
#> Balance summary across all treatment pairs
#> Type Max.Diff.Un Max.Diff.Adj
#> age Contin. 0.1532 0.0777
#> educ Contin. 0.4641 0.0847
#> married Binary 0.1931 0.0372
#> nodegree Binary 0.1336 0.0305
#> re74 Contin. 0.3390 0.1466
#> re75 Contin. 0.1744 0.1434
#>
#> Effective sample sizes
#> black hispan white
#> Unadjusted 243. 72. 299.
#> Adjusted 140.5 54.32 259.28
## IPW for longitudinal treatments
data("iptwExWide", package = "twang")
wmsm.out <- weightitMSM(list(tx1 ~ use0 + gender,
tx2 ~ use0 + gender + use1 + tx1,
tx3 ~ use0 + gender + use1 + tx1 + use2 + tx2),
data = iptwExWide,
stabilize = TRUE)
bal.tab(wmsm.out)
#> Call
#> weightitMSM(formula.list = list(tx1 ~ use0 + gender, tx2 ~ use0 +
#> gender + use1 + tx1, tx3 ~ use0 + gender + use1 + tx1 + use2 +
#> tx2), data = iptwExWide, stabilize = TRUE)
#>
#> Balance summary across all time points
#> Times Type Max.Diff.Adj
#> prop.score 1, 2, 3 Distance 0.3978
#> use0 1, 2, 3 Contin. 0.0672
#> gender 1, 2, 3 Binary 0.0102
#> use1 2, 3 Contin. 0.0286
#> tx1 2, 3 Binary 0.1602
#> use2 3 Contin. 0.0709
#> tx2 3 Binary 0.2345
#>
#> Effective sample sizes
#> - Time 1
#> Control Treated
#> Unadjusted 294. 706.
#> Adjusted 223.43 644.59
#> - Time 2
#> Control Treated
#> Unadjusted 492. 508.
#> Adjusted 417.01 446.82
#> - Time 3
#> Control Treated
#> Unadjusted 415. 585.
#> Adjusted 350.64 513.25