Skip to content

Implement Propensity Score Matching #858

Open

Description

@jburroni

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."

For example:

http://cran.r-project.org/web/packages/Matching/index.html
http://cran.r-project.org/web/packages/MatchIt/index.html
http://cran.r-project.org/web/packages/optmatch/index.html
http://cran.r-project.org/web/packages/cem/index.html

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."

Activity

  1. jburroni commented on May 29, 2013

    @jburroni
    Author

    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

  2. josef-pkt commented on May 30, 2013

    @josef-pkt
    Member

    @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?

  3. jburroni commented on May 31, 2013

    @jburroni
    Author

    @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?

  4. jburroni commented on May 31, 2013

    @jburroni
    Author

    @josef-pkt can you assign this issue to me? I'm not used to github nor git all

  5. josef-pkt commented on May 31, 2013

    @josef-pkt
    Member

    btw, is it right to upload a 2.5mb dataset?

    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.

  6. josef-pkt commented on May 31, 2013

    @josef-pkt
    Member

    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

  7. jburroni commented on May 31, 2013

    @jburroni
    Author

    @josef-pkt is there anything to compute mean differences?

  8. josef-pkt commented on May 31, 2013

    @josef-pkt
    Member

    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.)

  9. jburroni commented on May 31, 2013

    @jburroni
    Author

    Thanks.
    When creating stratas, I have to check that the covariates are balanced for each strata. CompareMean will do the work.

  10. josef-pkt commented on May 31, 2013

    @josef-pkt
    Member

    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.

  11. jburroni commented on Jun 5, 2013

    @jburroni
    Author

    @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.

  12. jburroni commented on Jun 5, 2013

    @jburroni
    Author

    update: They do check the balance in pscore and in the covariates

  13. josef-pkt commented on Jun 5, 2013

    @josef-pkt
    Member

    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. 14 remaining items

  15. jburroni commented on Jun 8, 2013

    @jburroni
    Author

    '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.

  16. patwater commented on Feb 20, 2015

    @patwater

    Hey what's the status on this? Don't see a propensity score module in statsmodels and would love to use one! Cheers

  17. jburroni commented on Feb 20, 2015

    @jburroni
    Author

    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:

    Hey what's the status on this? Don't see a propensity score module in
    statsmodels and would love to use one! Cheers

    —
    Reply to this email directly or view it on GitHub
    #858 (comment)
    .

    " 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 )

  18. patwater commented on Feb 20, 2015

    @patwater

    Ah roger that. That'd be awesome

  19. josef-pkt commented on Feb 20, 2015

    @josef-pkt
    Member

    @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.

  20. jburroni commented on Feb 20, 2015

    @jburroni
    Author

    I'm sorry to ask, but what is a PR?
    El feb 20, 2015 7:02 PM, "Josef Perktold" [email protected]
    escribió:

    @jburroni https://github.com/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.

    —
    Reply to this email directly or view it on GitHub
    #858 (comment)
    .

  21. josef-pkt commented on Feb 20, 2015

    @josef-pkt
    Member

    PR = pull request, request to merge the changes in a branch into master
    https://github.com/statsmodels/statsmodels/pulls

    we use also WIP PRs: pull requests that are Work In Progress to keep track of a branch and open it for discussion.

  22. jburroni commented on Feb 20, 2015

    @jburroni
    Author

    Thank you.
    I'll do so
    El feb 20, 2015 7:49 PM, "Josef Perktold" [email protected]
    escribió:

    PR = pull request, request to merge the changes in a branch into master
    https://github.com/statsmodels/statsmodels/pulls

    we use also WIP PRs: pull requests that are Work In Progress to keep
    track of a branch and open it for discussion.

    —
    Reply to this email directly or view it on GitHub
    #858 (comment)
    .

  23. jburroni commented on Feb 21, 2015

    @jburroni
    Author

    here is the pull request:
    #2288

    On Fri, Feb 20, 2015 at 7:51 PM, Javier Burroni [email protected]
    wrote:

    Thank you.
    I'll do so
    El feb 20, 2015 7:49 PM, "Josef Perktold" [email protected]
    escribió:

    PR = pull request, request to merge the changes in a branch into master

    https://github.com/statsmodels/statsmodels/pulls

    we use also WIP PRs: pull requests that are Work In Progress to keep
    track of a branch and open it for discussion.

    —
    Reply to this email directly or view it on GitHub
    #858 (comment)
    .

    " 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 )

  24. patwater commented on Feb 22, 2015

    @patwater

    High on my wish list too. Cheers

  25. vitillo commented on Mar 12, 2015

    @vitillo

    +1

  26. josef-pkt commented on Mar 12, 2015

    @josef-pkt
    Member

    If anyone wants too help out, then this would happen faster.
    For example #2288 is missing unit tests against Stata or R.

  27. josef-pkt commented on Jun 23, 2015

    @josef-pkt
    Member

    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

  28. jburroni commented on Jun 23, 2015

    @jburroni
    Author

    thanks,
    Looks useful

    On Mon, Jun 22, 2015 at 9:52 PM, Josef Perktold [email protected]
    wrote:

    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

    —
    Reply to this email directly or view it on GitHub
    #858 (comment)
    .

    " 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 )

  29. JohannesWiesner commented on Mar 17, 2020

    @JohannesWiesner

    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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions