Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mediation analysis #2352

Merged
merged 12 commits into from Nov 4, 2015
Merged

Mediation analysis #2352

merged 12 commits into from Nov 4, 2015

Conversation

kshedden
Copy link
Contributor

@kshedden kshedden commented Apr 4, 2015

This is an implementation of mediation analysis following the approach of Imai and collaborators.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 83.95% when pulling 00a8a43 on kshedden:mediation into a1f53b0 on statsmodels:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.05%) to 83.95% when pulling 00a8a43 on kshedden:mediation into a1f53b0 on statsmodels:master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 83.95% when pulling 836396e on kshedden:mediation into a1f53b0 on statsmodels:master.

@kshedden
Copy link
Contributor Author

kshedden commented Apr 5, 2015

@josef-pkt
Copy link
Member

just some general comments:

I looked at the reference briefly after you submitted the PR. I understand the basic idea but haven't figured out the assumptions yet. Overall I'm far behind in my readings about the differences of "causality" between statistics and econometrics, mainly Imbens and Rubin articles (and a new book).

Essentially, the direction that we have been and are going is that additional functionality in statistics are your area in statsmodels and I try to keep up enough to help with the integration into statsmodels.
(It took me more than half a year to understand the basic idea of GEE and it's relationship to GMM, and several years to understand most of GLM/LEF/QMLE)

One question here is where to put it. Should we create a new subdirectory causality or treatment or with a similar category? Or can we add it to stats or another existing subpackage.

Similar question for propensity score matching, regression discontinuity design, and whatever else will come into statsmodels in future.
I have no idea whether we will get SEM and graphical models anytime soon, but I doubt it.

@kshedden
Copy link
Contributor Author

Thanks for the comments. I don't have a strong opinion about where to put it, your suggestions are all fine with me.

I've been using this in a project and it holds up pretty well. I used to just use the simple method of multiplying coefficients but was never sure if that was meaningful outside of linear models. This approach seems more correct for generic use.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.04%) to 83.95% when pulling 511f602 on kshedden:mediation into a1f53b0 on statsmodels:master.

@sjgiorgi
Copy link

Line 351 of mediation.py: index = ["ACME (control)", "ACME (treated)", "ADE (control)", "ADE (treated)",
Line 356 of mediation.py: for i, vec in enumerate([self.ACME_ctrl, self.ACME_tx, self.ADE_tx, self.ADE_ctrl,

Seems like self.ADE_tx and self.ADE_ctrl should be switched on line 356?

@kshedden
Copy link
Contributor Author

@sjgiorgi yes, you appear to be correct. I have fixed it. Thanks. Any other comments are very welcome.

self.ACME_ctrl = indirect_effects_avg[0]
self.ACME_tx = indirect_effects_avg[1]
self.ADE_ctrl = direct_effects_avg[0]
self.ADE_tx = direct_effects_avg[1]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since these are user facing attributes, longer more descriptive names would be usefull

@josef-pkt
Copy link
Member

Looks good based on skimming the code

incomplete docstrings, needs eventually some standardized naming with treatment effects, and can go into new folder treatment (if we stick with that name)
related PR #2455 which doesn't allow different types of outcome or treatment models yet, and might be able to follow the same or similar pattern as here.

I did a bit of background reading and opened #2627 for a possible second approach.

@josef-pkt
Copy link
Member

I'm merging this, naming convention might and location will still change before 0.8 release

josef-pkt added a commit that referenced this pull request Nov 4, 2015
@josef-pkt josef-pkt merged commit a561db1 into statsmodels:master Nov 4, 2015
@josef-pkt
Copy link
Member

Thanks @kshedden

As I mentioned, I started to read to catch up with the topic but I'm still far behind.

@josef-pkt josef-pkt mentioned this pull request Feb 9, 2016
@kshedden kshedden deleted the mediation branch July 1, 2016 03:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants