facebookresearch / balance

The balance python package offers a simple workflow and methods for dealing with biased data samples when looking to infer from them to some target population of interest.
https://import-balance.org
GNU General Public License v2.0
681 stars 40 forks source link

Treatment in balance library for sample and target population #67

Closed sde2ds closed 11 months ago

sde2ds commented 11 months ago

I have one question regarding balance. You guys are using ipw as one of the method to balance covariate of sample dataset. Are we considering treatment 0 for sample df and treatment 1 for target df and then run weighting algorithm on top of combined dataset (concat(sample_df, target_df))?

talgalili commented 11 months ago

Hey @sde2ds Almost. You can see the code for ipw here: https://github.com/facebookresearch/balance/blob/7ad493786216b5a6fdea16eeee01cfecc88db28e/balance/weighting_methods/ipw.py#L506 You can think of target (population) as 0 and sample (panel) as 1. In practice, it's creating a 2D array that has weights instead of 1s.

Feel free to open the thread if you have more questions. And also to share any work you do with the package.

sde2ds commented 11 months ago

Hi @talgalili Thanks for your response. In the above reply you mean target as 1 not treatment. Am i right? Sure, will share some work in coming days

talgalili commented 11 months ago

Sorry, I wrote the wrong terms in the previous message.

In the context of survey statistics, it's target (or population) and sample (or panel). In casual inference it's often treatment and control. How to match the terms is your choice.

In 'balance', target is 0 and sample is 1. (I'll fix my previous message)