-
-
Notifications
You must be signed in to change notification settings - Fork 140
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
optional arguments for logistic_regression() in mediation_analysis() #245
optional arguments for logistic_regression() in mediation_analysis() #245
Conversation
…ration of mediation_analysis()
Codecov Report
@@ Coverage Diff @@
## master #245 +/- ##
=======================================
Coverage 98.99% 98.99%
=======================================
Files 19 19
Lines 3286 3287 +1
Branches 523 523
=======================================
+ Hits 3253 3254 +1
Misses 17 17
Partials 16 16
Continue to review full report at Codecov.
|
Hi @julibeg, That looks great, thanks! Have you made sure that changing the Thanks, |
I made sure by printing the |
Sorry for the delay. I added some tests that check if an error is thrown with Something else I noticed: When testing the indirect effect with |
Hi @julibeg, Thanks! I agree we can use with pytest.raises(AssertionError):
assert_almost_equal(ma['coef'][0], -0.0208, decimal=2)
with pytest.raises(AssertionError):
assert_almost_equal(ma['coef'][4], 0.0033, decimal=3) Right now, this will test that ma['coef'][0] is not equal to -0.0208, and as a result throw an assertion error. Is this the correct behavior? Thank you |
# Solve with 0 iterations and make sure that the results are different
ma = mediation_analysis(data=df, x='X', m='Mbin', y='Y', n_boot=2000,
logreg_kwargs=dict(max_iter=0)) This runs the mediation analysis while not allowing the solver to iterate so that the results are different (however, weirdly not all the coefs are different, just with pytest.raises(AssertionError):
assert_almost_equal(ma['coef'][0], -0.0208, decimal=2)
with pytest.raises(AssertionError):
assert_almost_equal(ma['coef'][4], 0.0033, decimal=3) This checks that the coefs are indeed different and that the assertion fails. |
Got it, thanks! So are we ready to merge? |
I think so |
As discussed in #244.
I added a dict
logreg_kwargs
with the arguments for logistic regression instead of**kwargs
as this might be cleaner at some later time when you might also want to pass arguments to other functions called bymediation_analysis()
(e.g.linear_regression()
). If you prefer the**kwargs
solution, let me know and I'll change it.Also, I'm not really familiar with Sphinx, please check if the docstring correct.