Closed kkranker closed 6 years ago
Hi Keith,
Thank you so much for letting me know about this. It is indeed a bug with cobalt. cobalt currently does not recognize sampling weights from CBPS objects. I will change this and ensure it works in the next update.
However, I was able to replicate the results from CBPS::balance()
using bal.tab()
on a weightit object. WeightIt is a package that provides a single interface to many other R packages for estimating weights, including CBPS, extends the capabilities of those packages, and is compatible with cobalt. The following code provides exactly the same input and estimates the same weights that your call to CBPS does:
fit.w <- weightit(treat ~ age + educ + re75 + re74 + I(re75==0) + I(re74==0),
data = LaLonde, estimand = "att", s.weights = LaLonde$wgt,
method = "cbps")
Using bal.tab()
on fit.w gives the correct results that match with CBPS::balance()
:
bal.tab(fit.w, disp.means = TRUE)
Note that the "unadjusted" values are actually adjusted with just the sampling weights, and the "adjusted" values are adjusted with both the sampling and balancing weights. As with CBPS objects, you can use get.w(fit.w)
to extract the combined balancing and sampling weights from the weightit object.
Okay -- thanks for the quick reply and explaining the workaround with weightit()
.
Issue fixed. Summary statistics should be correct now. To get defaults to work correctly, you should include sampling weights in the call to bal.tab()
, as in
bal.tab(fit, s.weights = LaLonde$wgt)
I'm closing this issue now. Thank you for raising it.
Thanks!
I have constructed CBPS object using
CBPS(.... , sample.weights=mydata$myweight)
. Afterward, cobalt'sbal.tab()
function gives odd results. For example, the means frombal.tab()
don't match the means frombalance()
function from the CBPS package. I don't thinkbal.tab()
is incorporating thesample.weights
appropriately. Any suggestions?Here's some example code to reproduce the problem:
I have CBPS version 0.17 and cobalt version 3.2.0.