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

Cumulative Incidence (Kaplan-Meier) for competing risks. #491

Merged
merged 8 commits into from
Nov 27, 2024

Conversation

mvlvrd
Copy link
Contributor

@mvlvrd mvlvrd commented Nov 5, 2024

Add non-parametric Cumulative Incidence (Kaplan-Meier) for competing risks. Tests included.

Checklist

What does this implement/fix? Explain your changes
Implements cumulative incidence estimator for the competing risks case. Confidence Intervals are not implemented but are under development.

@mvlvrd mvlvrd force-pushed the competing_risks branch 2 times, most recently from faed249 to a65a142 Compare November 6, 2024 09:35
Copy link

codecov bot commented Nov 6, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.23%. Comparing base (41a5200) to head (9fc899a).
Report is 65 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #491      +/-   ##
==========================================
+ Coverage   98.21%   98.23%   +0.02%     
==========================================
  Files          37       37              
  Lines        3521     3564      +43     
  Branches      464      472       +8     
==========================================
+ Hits         3458     3501      +43     
  Misses         30       30              
  Partials       33       33              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@mvlvrd
Copy link
Contributor Author

mvlvrd commented Nov 7, 2024

The codacy linter triggers for unused unpacked assignments, however the ruff linter doesn't. Perhaps it would be nice to make them consistent, though is not a big issue. (I can open a new issue/PR if needed, it is trivial to fix it from the ruff side).

@mvlvrd mvlvrd force-pushed the competing_risks branch 2 times, most recently from 9b03384 to 477bdd0 Compare November 7, 2024 13:16
Copy link
Owner

@sebp sebp left a comment

Choose a reason for hiding this comment

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

This is great, thanks a lot!

The code seems to be correct to me. I would suggest to improve the API docs a little bit to avoid ambiguities.

In addition, I'm not sure if certain corner cases are covered. For instance, what happens if no event has been observed for one (or more) competing risk?

I would appreciate if a test case with more than 2 competing risks could be added.

@mvlvrd
Copy link
Contributor Author

mvlvrd commented Nov 15, 2024

Thanks so much for the review!
I think I have addressed most of your points. I have been looking for a real dataset with more than two risks, but I couldn't find one, so I added a simulated one. Corner cases like zero events for one (or more) particular risk are not included and raise an error.

I also changed the function name (removing the reference to Kaplan-Meier). This is because I found a couple of papers that use KM for the naive extension of KM to the competing risks case, while we are using the rigorous estimator that does not assume independence between risks.

and its entry in datasets/data/README.md
@sebp sebp merged commit 3a3ef80 into sebp:master Nov 27, 2024
16 of 17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add Kaplan-Meier estimator for competing risks.
2 participants