2
$\begingroup$

I am doing propensity score weighting with the package "Weightit" and I want to have a Table 1 "Before and After Weighting" like this one:

enter image description here

As you can see, data are displayed EITHER as MEAN±SD or frequency(percentage) depending whether the variable is continous or categorical. I want to do the same thing. This is my code:

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

W.out <- weightit(treat ~ age + educ + race + married + nodegree + re74 + re75,
                  data = lalonde, estimand = "ATT", method = "ps")
W.out

bal.tab(W.out, stats = c("m", "v"), thresholds = c(m = .05), disp=c("means", "sds"))

However, by using bal.tab from cobalt package the problem is that it only shows means (SD) and DOESN'T SHOW frequency(percentage) for categorical variables as I want to. How can I overcome this problem? I can also use another package both for IPTW and for creating tables. I just want to perform IPTW and create a table before and after.

$\endgroup$

1 Answer 1

1
$\begingroup$

It's kind of hard to talk about frequencies with weights. Let's say there are two units, one with the condition and one without. The frequency of the condition is 1 and the rate is 50%. But now let's give the unit with the condition a weight of .75 and the other unit a weight of .25. What is the frequency of the event? It's clear the weighted rate of the event is 75%. But what is the frequency? Is it .75? That doesn't make much sense because that would indicate the frequency decreased even though the unit with the condition received a higher weight. Is it 1? That doesn't make much sense because it ignores the weights, though it does reflect that only one unit, however they are weighted, has the condition. Is it 1.5? That also doesn't make much sense because it doesn't really make sense to talk about a frequency that isn't a whole number. So what number should be produced?

My intuition says don't report weighted frequencies. Just report weighted rates. It's the rates are are more meaningful when assessing covariate balance or generalizability to other population anyway. The frequency is a function of the rate and the sample size, but the sample size is incidental. A frequency of 100 doesn't tell you whether the condition is rare or common (it would be rare in a sample size of 1,000,000 but common in a sample size of 150). Only the rate does.

If you are absolutely desperate to report a frequency, multiply the weighted rate by the sample size. That will still leave you with a fractional number that doesn't make much sense, but at least it's close to what you probably want.

$\endgroup$
6
  • $\begingroup$ Thank you for your answer. I understand what you mean. So in your opinion where do the numbers in the table I attached come from? I find it hard to understand. $\endgroup$ Commented Apr 5, 2023 at 0:11
  • $\begingroup$ Also another question I have is that I often find myself with a decreased Weighted sample size compared to the Unweighted. How does that happen? I tried to explain in this question stats.stackexchange.com/questions/611902/… $\endgroup$ Commented Apr 5, 2023 at 0:14
  • $\begingroup$ Last question! Sorry I am new. How can I obtain the weighted rate automatically on bal.tab/WeightIt? $\endgroup$ Commented Apr 5, 2023 at 0:22
  • $\begingroup$ That's exactly what the means in the balance table are. The weighted mean of a binary variable is the weighted rate. $\endgroup$
    – Noah
    Commented Apr 5, 2023 at 0:59
  • $\begingroup$ I have no idea how they computed the table. It looks like they trimmed the sample (discarded units with extreme weights) so maybe those are the unweighted frequencies in the trimmed sample. That's my guess because the sample sizes change even though in IPTW without trimming the sample sizes don't change (the ESS does, though, which I'll discuss in your other question). $\endgroup$
    – Noah
    Commented Apr 5, 2023 at 1:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.