You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
It would be nice to have a propensity score matching implementation.
We can follow the description given at:
Dehejia, Rajeev. “Practical Propensity Score Matching: a Reply to Smith and Todd.” Journal of Econometrics 125, no. 1–2 (March 2005): 355–364. doi:10.1016/j.jeconom.2004.04.012.
Dehejia, Rajeev H, and Sadek Wahba. “Propensity Score-matching Methods for Nonexperimental Causal Studies.” Review of Economics and Statistics 84, no. 1 (2002): 151–161.
Also,
"Other software packages promise: "Provides functions for multivariate and propensity score matching and for finding optimal balance based on a genetic search algorithm. A variety of univariate and multivariate metrics to determine if balance has been obtained are also provided."
but
"None of this code is BSD compatible, so we can't just translate it,
but going through these packages' docs may help give an idea of what
is to be done."
@jburroni I tried to look at your branch but github seems to have problems to display branches where the branch name is only numbers. Can you rename your branch?
It's a bit heavy, and I prefer to keep it out of the repository for now. It wouldn't be easy to remove it from the git history if we include it. We might include it later, in an archive/zip file it might not be so large.
You could send it to me privately before your code is ready to be tried out. We could also check if we can make it publicly available somewhere else.
I'm not able to assign the issue to you. We never assign issues, and just add comments in the issue about who is working on it (or it's anyway obvious from the comments). I just tried for the first time to assign an issue, and it looks like I can only assign to one of the committers of the statsmodels (master) repository.
Thanks for renaming, github now displays it properly as branch, with easy view of the diff between branch and master. For example here jburroni/statsmodels@master...psmatch
If you have one-to-one matching, then it is just the paired difference (x1 - x2).mean(). One sample and paired sample t-tests are in scipy.stats and in statsmodels.stats.weightstats.
If you have many to one matching, then you will have to loop yourself. There is similar code used in the kernel regression in statsmodels.nonparametric, but that also loops over all observations and might not help you directly. (It might be worth looking there, if you, later, want to add kernel based mean comparison.)
CompareMeans should work vectorized with observations in rows and variables in columns. (If it doesn't it's a bug.)
But it will do separate t_tests on each pair of columns, i.e. covariate/exog.
I think an F_test could check all covariates at the same time (joint hypothesis that all differences are zero), but I don't think we have one ready made for this case.
@josef-pkt [related to strata]: I've just realized a big difference with other packages. When computing the number of strata, for each stratum they check the hypothesis of no difference in mean in the propensity score between the treated and the control group. But Dehejia Wahba 2002 suggest the check over the covariates for each stratum.
My impression:
to get a good match we need to have both pscore and covariates close in the matched pair or group.
matching pscore is also done in a later stage when we do the actual matching not when we calculate the pscore as in Dehejia Wahba.
In the pscore strata we already have grouped the individuals to have a close pscore, so we mainly want to match covariates, the way I understand DW.
in general:
It's always good to match what the others, especially Stata, are doing unless we have a strong reason to do something different.
In this case: Can you add an option that does the additional check of pscore, instead of just the testing the covariates in each stratum, but keep the DW version also?
'Most of the algorithms can be described in the following way: First, check if within a stratum the propensity score is balanced. If not, strata are too large and need to be split. If, conditional on the propensity score being balanced, the covariates are unbalanced, the specification of the propensity score is not adequate and has to be re-specified, e.g. through the addition of higher- order terms or interactions (Dehejia and Wahba, 1999).' from Caliendo, Marco, and Sabine Kopeinig. “Some Practical Guidance for the Implementation of Propensity Score Matching.” Journal of Economic Surveys 22, no. 1 (2008): 31–72.
@jburroni I also had added propensity score matching as one of the GSOC topics earlier today.
You could also open a PR with your work so far (in whatever shape it's in) so that someone else can take over if you don't have time to work on this anymore.
This is on my high priority wishlist for statsmodels.
Activity
jburroni commentedon May 29, 2013
data to reproduce: Dehejia, Rajeev H, and Sadek Wahba. “Propensity Score-matching Methods for Nonexperimental Causal Studies.” Review of Economics and Statistics 84, no. 1 (2002): 151–161.
http://users.nber.org/~rdehejia/nswdata2.html
josef-pkt commentedon May 30, 2013
@jburroni I tried to look at your branch but github seems to have problems to display branches where the branch name is only numbers. Can you rename your branch?
jburroni commentedon May 31, 2013
@josef-pkt https://github.com/jburroni/statsmodels/tree/psmatch
The code is no yet meaningful. I'm trying to get DW's results and then I will create some useful code
btw, is it right to upload a 2.5mb dataset?
jburroni commentedon May 31, 2013
@josef-pkt can you assign this issue to me? I'm not used to github nor git all
josef-pkt commentedon May 31, 2013
It's a bit heavy, and I prefer to keep it out of the repository for now. It wouldn't be easy to remove it from the git history if we include it. We might include it later, in an archive/zip file it might not be so large.
You could send it to me privately before your code is ready to be tried out. We could also check if we can make it publicly available somewhere else.
I'm not able to assign the issue to you. We never assign issues, and just add comments in the issue about who is working on it (or it's anyway obvious from the comments). I just tried for the first time to assign an issue, and it looks like I can only assign to one of the committers of the statsmodels (master) repository.
josef-pkt commentedon May 31, 2013
Thanks for renaming, github now displays it properly as branch, with easy view of the diff between branch and master. For example here jburroni/statsmodels@master...psmatch
jburroni commentedon May 31, 2013
@josef-pkt is there anything to compute mean differences?
josef-pkt commentedon May 31, 2013
I'm not sure what you need.
If you have one-to-one matching, then it is just the paired difference (x1 - x2).mean(). One sample and paired sample t-tests are in scipy.stats and in statsmodels.stats.weightstats.
If you have many to one matching, then you will have to loop yourself. There is similar code used in the kernel regression in
statsmodels.nonparametric, but that also loops over all observations and might not help you directly. (It might be worth looking there, if you, later, want to add kernel based mean comparison.)jburroni commentedon May 31, 2013
Thanks.
When creating stratas, I have to check that the covariates are balanced for each strata. CompareMean will do the work.
josef-pkt commentedon May 31, 2013
CompareMeans should work vectorized with observations in rows and variables in columns. (If it doesn't it's a bug.)
But it will do separate t_tests on each pair of columns, i.e. covariate/exog.
I think an F_test could check all covariates at the same time (joint hypothesis that all differences are zero), but I don't think we have one ready made for this case.
jburroni commentedon Jun 5, 2013
@josef-pkt [related to strata]: I've just realized a big difference with other packages. When computing the number of strata, for each stratum they check the hypothesis of no difference in mean in the propensity score between the treated and the control group. But Dehejia Wahba 2002 suggest the check over the covariates for each stratum.
jburroni commentedon Jun 5, 2013
update: They do check the balance in pscore and in the covariates
josef-pkt commentedon Jun 5, 2013
Not sure, I don't have the context right now.
My impression:
to get a good match we need to have both pscore and covariates close in the matched pair or group.
matching pscore is also done in a later stage when we do the actual matching not when we calculate the pscore as in Dehejia Wahba.
In the pscore strata we already have grouped the individuals to have a close pscore, so we mainly want to match covariates, the way I understand DW.
in general:
It's always good to match what the others, especially Stata, are doing unless we have a strong reason to do something different.
In this case: Can you add an option that does the additional check of pscore, instead of just the testing the covariates in each stratum, but keep the DW version also?
14 remaining items
jburroni commentedon Jun 8, 2013
'Most of the algorithms can be described in the following way: First, check if within a stratum the propensity score is balanced. If not, strata are too large and need to be split. If, conditional on the propensity score being balanced, the covariates are unbalanced, the specification of the propensity score is not adequate and has to be re-specified, e.g. through the addition of higher- order terms or interactions (Dehejia and Wahba, 1999).' from Caliendo, Marco, and Sabine Kopeinig. “Some Practical Guidance for the Implementation of Propensity Score Matching.” Journal of Economic Surveys 22, no. 1 (2008): 31–72.
patwater commentedon Feb 20, 2015
Hey what's the status on this? Don't see a propensity score module in statsmodels and would love to use one! Cheers
jburroni commentedon Feb 20, 2015
I couldn't finish this feature.
I can retake it in about a month
On Fri, Feb 20, 2015 at 5:05 PM, Patrick Atwater [email protected]
wrote:
" To be is to do " ( Socrates )
" To be or not to be " ( Shakespeare )
" To do is to be " ( Sartre )
" Do be do be do " ( Sinatra )
patwater commentedon Feb 20, 2015
Ah roger that. That'd be awesome
josef-pkt commentedon Feb 20, 2015
@jburroni I also had added propensity score matching as one of the GSOC topics earlier today.
You could also open a PR with your work so far (in whatever shape it's in) so that someone else can take over if you don't have time to work on this anymore.
This is on my high priority wishlist for statsmodels.
jburroni commentedon Feb 20, 2015
I'm sorry to ask, but what is a PR?
El feb 20, 2015 7:02 PM, "Josef Perktold" [email protected]
escribió:
josef-pkt commentedon Feb 20, 2015
PR = pull request, request to merge the changes in a branch into master
https://github.com/statsmodels/statsmodels/pulls
we use also
WIPPRs: pull requests that are Work In Progress to keep track of a branch and open it for discussion.jburroni commentedon Feb 20, 2015
Thank you.
I'll do so
El feb 20, 2015 7:49 PM, "Josef Perktold" [email protected]
escribió:
jburroni commentedon Feb 21, 2015
here is the pull request:
#2288
On Fri, Feb 20, 2015 at 7:51 PM, Javier Burroni [email protected]
wrote:
" To be is to do " ( Socrates )
" To be or not to be " ( Shakespeare )
" To do is to be " ( Sartre )
" Do be do be do " ( Sinatra )
patwater commentedon Feb 22, 2015
High on my wish list too. Cheers
vitillo commentedon Mar 12, 2015
+1
josef-pkt commentedon Mar 12, 2015
If anyone wants too help out, then this would happen faster.
For example #2288 is missing unit tests against Stata or R.
josef-pkt commentedon Jun 23, 2015
reference to a survey paper
Stuart, Elizabeth A. 2010. “Matching Methods for Causal Inference: A Review and a Look Forward.” Statistical Science 25 (1): 1–21. doi:10.1214/09-STS313. http://projecteuclid.org/euclid.ss/1280841730
jburroni commentedon Jun 23, 2015
thanks,
Looks useful
On Mon, Jun 22, 2015 at 9:52 PM, Josef Perktold [email protected]
wrote:
" To be is to do " ( Socrates )
" To be or not to be " ( Shakespeare )
" To do is to be " ( Sartre )
" Do be do be do " ( Sinatra )
JohannesWiesner commentedon Mar 17, 2020
It would be very nice, if propensity matching could be implemented. I currently use both
https://github.com/kellieotto/pscore_match
https://github.com/benmiroglio/pymatch
as a workaround, but both packages are deprecated and seem to be not maintained anymore.