I am trying to produce a classical "before" and "after" table reporting original cohort and pseudopopulation before and after an IPTW analysis using the WeightIt package.
Essentially, what I want is something like what is reported in the the example provided here: https://stats.stackexchange.com/questions/496599/calculate-single-absolute-standardized-difference-across-levels-of-a-categorical
I've tried to use bal.tab
for that, but it seems that only balance summary can be accessed, and not the mean and SD or count and percentages for continuous and binary variables, respectively.
I can I do that?
I provide a workable example of an IPTW analysis.
library(WeightIt)
library(cobalt)
library(survey)
W.out <- weightit(treat ~ age educ race married nodegree re74 re75,
data = lalonde, estimand = "ATT", method = "ps")
bal.tab(W.out)
CodePudding user response:
You can use bal.tab()
for this. Just set disp = c("means", "sds")
. It's not as pretty as a tableone
table but it does contain the same information and is immediately compatible with WeightIt
. Note that the idea of a "weighted count" doesn't really apply because the weights are unscaled. Weighted means/proportions are valid, though, and you should report them and can do so with bal.tab()
.