ngreifer / WeightIt

WeightIt: an R package for propensity score weighting
https://ngreifer.github.io/WeightIt/
102 stars 12 forks source link

How can the weights be extracted as a column added to the original dataset? #23

Closed yatefi closed 3 years ago

yatefi commented 3 years ago

Hi, I'm using the package to compute the weights, but the purpose of these weighting methods is to ultimately use the weights as regression weights in a subsequent analysis. However, the output is given as an object. How can I add the weights to the original data set as a column so that I can use it as regression weights in the subsequent analysis? Thanks!

ngreifer commented 3 years ago

You can just supply the weights directly from the object to the modeling function, as done in the WeightIt tutorial. If you want to use the weights outside R (e.g., in Stata), you can create a new column in your dataset and assign the weights to it, e.g., data$weights <- w.out$weights, where data is your original dataset and w.out is the weightit() output object.

yatefi commented 3 years ago

Awesome! thanks for the quick response!