Balance Statistics for Longitudinal Datasets
Generates balance statistics for data coming from a longitudinal treatment scenario. The primary input is in the form of a list of formulas or data.frame
s contain the covariates at each time point. bal.tab()
automatically classifies this list as either a data.frame.list
or formula.list
, respectively.
## S3 method for class 'data.frame.list' bal.tab(x, treat.list = NULL, data = NULL, weights = NULL, stats, int = FALSE, poly = 1, distance.list = NULL, addl.list = NULL, method, continuous, binary, s.d.denom, thresholds = NULL, cluster = NULL, imp = NULL, pairwise = TRUE, s.weights = NULL, estimand = "ATE", abs = FALSE, subset = NULL, quick = TRUE, ...) ## S3 method for class 'formula.list' bal.tab(x, data = NULL, ...)
x |
either a list of data frames containing all the covariates to be assessed at each time point or a list of formulas with the treatment for each time period on the left and the covariates for which balance is to be displayed on the right. Covariates to be assessed at multiple points must be included in the entries for each time point. Data must be in the "wide" format, with one row per unit. If a formula list is supplied, an argument to |
treat.list |
treatment status for each unit at each time point. This can be specified as a list or data frame of vectors, each of which contains the treatment status of each individual at each time point, or a list or vector of the names of variables in |
data |
for |
weights |
optional; a vector, list, or data frame containing weights for each unit or a string containing the names of the weights variables in |
stats |
|
int |
|
poly |
|
distance.list |
optional; distance values (e.g., propensity scores) for each unit. These can be specified as a list of vectors or data frames containing the distance values (one for each time point), or as a single vector or data frame to be applied at all times points. The vectors or data frames can be replaced with the names of variables in |
addl.list |
optional; additional covariates for which to present balance. These may be covariates included in the original dataset but not included in |
method |
a character vector containing the method of adjustment, if any. Currently only "weighting" is supported. |
continuous |
whether mean differences for continuous variables should be standardized ( |
binary |
whether mean differences for binary variables (i.e., difference in proportion) should be standardized ( |
s.d.denom |
|
thresholds |
a named vector of balance thresholds, where the name corresponds to the statistic (i.e., in |
cluster |
either a vector containing cluster membership for each unit or a string containing the name of the cluster membership variable in |
imp |
either a vector containing imputation indices for each unit or a string containing the name of the imputation index variable in |
pairwise |
when treatment is multi-category, whether balance should be computed for pairs of treatments or for each treatment against all groups combined. See |
s.weights |
optional; either a vector containing sampling weights for each unit or a string containing the name of the sampling weight variable in |
estimand |
the causal estimand of interest. This value is used to set |
abs |
|
subset |
A |
quick |
|
... |
For |
bal.tab.formula.list()
and bal.tab.data.frame.list()
generate a list of balance summaries for each time point based on the treatments and covariates provided. All data must be in the "wide" format, with exactly one row per unit and columns representing variables at different time points. See the weightitMSM()
documentation for an example of how to transform long data into wide data using reshape()
.
All balance statistics are calculated whether they are displayed by print or not, unless quick = TRUE
. The threshold
argument controls whether extra columns should be inserted into the Balance table describing whether the balance statistics in question exceeded or were within the threshold. Including these thresholds also creates summary tables tallying the number of variables that exceeded and were within the threshold and displaying the variables with the greatest imbalance on that balance measure.
Multiple sets of weights can be supplied simultaneously by including entering a data frame or a character vector containing the names of weight variables found in data
or a list thereof. The arguments to method
, s.d.denom
, and estimand
, if any, must be either the same length as the number of sets of weights or of length one, where the sole entry is applied to all sets. When standardized differences are computed for the unadjusted group, they are done using the first entry to s.d.denom
or estimand
. When only one set of weights is supplied, the output for the adjusted group will simply be called "Adj"
, but otherwise will be named after each corresponding set of weights. Specifying multiple sets of weights will also add components to other output of bal.tab()
.
An object of class bal.tab.msm
containing balance summaries at each time point. Each balance summary is its own bal.tab
object. See bal.tab.msm
for more details.
See bal.tab() base methods
for more detailed information on the value of the bal.tab
objects produced for each time point.
Noah Greifer
bal.tab() base methods
for details of calculations.
bal.tab.msm
for output and related options.
bal.tab.cluster
for more information on clustered data.
bal.tab.imp
for more information on multiply imputed data.
bal.tab.multi
for more information on multi-category treatments.
data("iptwExWide", package = "twang") library("cobalt") ## Estimating longitudinal propensity scores and weights ps1 <- glm(tx1 ~ age + gender + use0, data = iptwExWide, family = "binomial")$fitted.values w1 <- ifelse(iptwExWide$tx1 == 1, 1/ps1, 1/(1-ps1)) ps2 <- glm(tx2 ~ age + gender + use0 + tx1 + use1, data = iptwExWide, family = "binomial")$fitted.values w2 <- ifelse(iptwExWide$tx2 == 1, 1/ps2, 1/(1-ps2)) ps3 <- glm(tx3 ~ age + gender + use0 + tx1 + use1 + tx2 + use2, data = iptwExWide, family = "binomial")$fitted.values w3 <- ifelse(iptwExWide$tx3 == 1, 1/ps3, 1/(1-ps3)) w <- w1*w2*w3 # Formula interface plus addl.list: bal.tab(list(tx1 ~ use0 + gender, tx2 ~ use0 + gender + use1 + tx1, tx3 ~ use0 + gender + use1 + tx1 + use2 + tx2), data = iptwExWide, weights = w, distance.list = list(~ps1, ~ps2, ~ps3), addl.list = ~age*gender, un = TRUE) # data frame interface: bal.tab(list(iptwExWide[c("use0", "gender")], iptwExWide[c("use0", "gender", "use1", "tx1")], iptwExWide[c("use0", "gender", "use1", "tx1", "use2", "tx2")]), treat.list = iptwExWide[c("tx1", "tx2", "tx3")], weights = w, distance.list = list(~ps1, ~ps2, ~ps3), un = TRUE)
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.