# Survival analysis in Julia

**URL:** <https://discourse.julialang.org/t/survival-analysis-in-julia/969>\
**Category:** Statistics\
**Created:** [December 15, 2016, 2:06pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969 "2016-12-15T14:06:14Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [December 15, 2016, 2:06pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/1 "2016-12-15T14:06:14Z")

</div>

Hi all,  
What are good packages for survival analysis in Julia (i.e. working with truncated data, Kaplan-Meier estimator, Cox model and so on…)? So far I only found packages that seemed incomplete/abandoned (e.g.[[https://github.com/ContaTP/Survival.jl](https://github.com/ContaTP/Survival.jl)] ([https://github.com/ContaTP/Survival.jl](https://github.com/ContaTP/Survival.jl))) or this unmerged [PR](https://github.com/simonster/GLMNet.jl/pull/10) in GLMnet.  
I wanted to know if I’m missing something and if/where this set of analysis will become part of Julia Statistics ecosystem.

Thanks,  
Pietro

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [December 16, 2016, 9:28am UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/2 "2016-12-16T09:28:59Z")

</div>

There’s also [https://github.com/kkholst/EventHistory.jl](https://github.com/kkholst/EventHistory.jl). But none of the packages appear to be under very active development. As often with free software, it will depend on whether somebody steps in or not…

---

<div class="post-metadata">

**Author:** ![dpsanders](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dpsanders/32/3573_2.png) [@dpsanders](https://discourse.julialang.org/u/dpsanders)\
**Post date:** [December 16, 2016, 1:09pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/3 "2016-12-16T13:09:13Z")

</div>

If you need a stop-gap measure, you can call into Python or R. But the best solution may be to write your own package, as @nalimilan suggests.

---

<div class="post-metadata">

**Author:** ![alexhallam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexhallam/32/435_2.png) [@alexhallam](https://discourse.julialang.org/u/alexhallam)\
**Post date:** [January 6, 2017, 7:34pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/4 "2017-01-06T19:34:35Z")

</div>

I was just wondering the same thing. I am taking survival analysis this semester. Looks like I will have to lean on R. [https://www.openintro.org/download.php?file=survival\_analysis\_in\_R&amp;referrer](https://www.openintro.org/download.php?file=survival_analysis_in_R&amp;referrer)

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [January 7, 2017, 3:55pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/5 "2017-01-07T15:55:56Z")

</div>

In the end I started working on it, although very slowly as I don’t have as much time as I’d like to dedicate to this project. Out of curiosity, what type of analysis would you need? Here’s a list of what I’m planning to implement:

- Kaplan-Meier estimate of the survival function
- Nelson-Aalen estimate of the cumulative hazard
- Some smoothing to get hazard from cumulative hazard
- Cox proportional hazard models
- Accelerated failure time models

Feel free to let me know if there are more things you’d like to see implemented/implement yourself.

---

<div class="post-metadata">

**Author:** ![alexhallam](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/alexhallam/32/435_2.png) [@alexhallam](https://discourse.julialang.org/u/alexhallam)\
**Post date:** [January 7, 2017, 5:26pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/6 "2017-01-07T17:26:57Z")

</div>

It is hard for me to know. I am just doing a grad level class - no research. If you are willing I would love to contribute. Let me know what you need.

---

<div class="post-metadata">

**Author:** ![piever](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/piever/32/1815_2.png) [@piever](https://discourse.julialang.org/u/piever)\
**Post date:** [January 7, 2017, 6:43pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/7 "2017-01-07T18:43:47Z")

</div>

Cool! I’ll try to work a bit more on the core structure of the thing and, as soon as the “skeleton” is clear I’ll open an issue with a “to do list”.

---

<div class="post-metadata">

**Author:** ![nalimilan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nalimilan/32/147_2.png) [@nalimilan](https://discourse.julialang.org/u/nalimilan)\
**Post date:** [September 10, 2019, 8:38pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/8 "2019-09-10T20:38:28Z")

</div>

For anybody bumping into this old thread, there is now also [Survival.jl](https://github.com/JuliaStats/Survival.jl/) in JuliaStats.

---

<div class="post-metadata">

**Author:** ![compleat](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/compleat/32/8958_2.png) [@compleat](https://discourse.julialang.org/u/compleat)\
**Post date:** [April 23, 2020, 11:00am UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/9 "2020-04-23T11:00:24Z")

</div>

Hi. Yes, thanks for the update. Unfortunately Survival.jl does not include Accelerated Failure time models. Also, quite an important feature which is missing is left-censoring (or, equivalently, stratification).

I tried to install AcceleratedFailure from the link and it seemed to load OK, but when I typed

using AcceleratedFailure

I got:

ERROR: ArgumentError: Package AcceleratedFailure [3f1df495-9e49-5d95-a7ce-ef4aed63100f] is required but does not seem to be installed:

- Run `Pkg.instantiate()` to install all recorded dependencies.

I ran the instantiate command as suggested, but nothing happened and it still did not work.

I thought that when a package installs OK, then ‘using’ should work after that?

Thanks for any help (or any update on alternative packages?)

PS My interest in this now is Covid-19 related.

---

<div class="post-metadata">

**Author:** ![Juan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/juan/32/7657_2.png) [@Juan](https://discourse.julialang.org/u/Juan)\
**Post date:** [February 16, 2021, 4:53pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/10 "2021-02-16T16:53:00Z")

</div>

I went to the link but I could find any solved example. The docs are very minimal.

---

<div class="post-metadata">

**Author:** ![RaphaelS1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raphaels1/32/39133_2.png) [@RaphaelS1](https://discourse.julialang.org/u/RaphaelS1)\
**Post date:** [September 1, 2022, 6:32pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/11 "2022-09-01T18:32:55Z")

</div>

Appreciate this is over a year late but might be useful for anyone who stumbles across this thread like I did when searching the same question: just released [SurvivalAnalysis.jl](https://juliahub.com/ui/Packages/SurvivalAnalysis/N9zkY/0.1.0?t=2) which is in active development and will hopefully cover above needs!

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [September 1, 2022, 8:03pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/12 "2022-09-01T20:03:45Z")

</div>

I really should publish my result, but I have done some survival analysis using Bayesian models and got dramatically different results from the Kaplan Meier curves my colleagues were plotting. I assumed it was something wrong with my model. But after weeks of debugging it turned out my model was correct. Kaplan-Meier curves were TERRIBLE for the data we were looking at. This was cancer data. The assumptions surrounding K-M missingness are usually very bad for cancer data. Missingness there is very often about a patient dying before their next followup and the study not being able to contact the patient or bereaved family. I did simulations showing that K-M does a terrible job under these conditions. Please don’t use K-M for studying cancer.

---

<div class="post-metadata">

**Author:** ![CameronBieganek](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/cameronbieganek/32/6915_2.png) [@CameronBieganek](https://discourse.julialang.org/u/CameronBieganek)\
**Post date:** [September 1, 2022, 8:26pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/13 "2022-09-01T20:26:02Z")

</div>

> [@RaphaelS1](#):
>
> just released [SurvivalAnalysis.jl](https://juliahub.com/ui/Packages/SurvivalAnalysis/N9zkY/0.1.0?t=2)

Nice work! I recommend creating a separate package announcement under the “Package Announcements” category, so that your announcement reaches more people. 🙂

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [September 1, 2022, 9:12pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/14 "2022-09-01T21:12:45Z")

</div>

Come to think of it @RaphaelS1 your package may very well make it easier for me to get a publishable article. I didn’t want to jump back and forth between my simulations in Julia and making K-M curves in R… it was too much hassle. now that I can KM curve in Julia, it’ll be easier to get those results out there.

---

<div class="post-metadata">

**Author:** ![RaphaelS1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raphaels1/32/39133_2.png) [@RaphaelS1](https://discourse.julialang.org/u/RaphaelS1)\
**Post date:** [September 2, 2022, 7:58am UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/15 "2022-09-02T07:58:59Z")

</div>

Thanks for the tip! [Done now](https://discourse.julialang.org/t/ann-survivalanalysis-jl/86680)!

---

<div class="post-metadata">

**Author:** ![RaphaelS1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raphaels1/32/39133_2.png) [@RaphaelS1](https://discourse.julialang.org/u/RaphaelS1)\
**Post date:** [September 2, 2022, 8:00am UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/16 "2022-09-02T08:00:27Z")

</div>

I’d be interested in chatting about your paper. I’ve done a fair amount of work with non-small cell lung cancer and whilst I wouldn’t use KM for prediction (ever) it’s been fine for basic estimates.

Anyway happy to hear the package will help you publish. Please let me know if you encounter any bugs or have any feature requests, just post them in the [repo](https://github.com/RaphaelS1/SurvivalAnalysis.jl).

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [September 2, 2022, 2:08pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/17 "2022-09-02T14:08:21Z")

</div>

It all depends on your study design and followup. The key finding was when missingness has to do with patients dying and the study not being able to contact the family to get date of death. When missingness is due to this, KM curves wind up way off. Simulation studies confirm the issue.

---

<div class="post-metadata">

**Author:** ![RaphaelS1](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/raphaels1/32/39133_2.png) [@RaphaelS1](https://discourse.julialang.org/u/RaphaelS1)\
**Post date:** [September 2, 2022, 2:28pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/18 "2022-09-02T14:28:44Z")

</div>

Oh for sure when the independent censoring assumption is violated. I’ve read some good papers on this, I can share if useful?

---

<div class="post-metadata">

**Author:** ![dlakelan](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dlakelan/32/8491_2.png) [@dlakelan](https://discourse.julialang.org/u/dlakelan)\
**Post date:** [September 2, 2022, 2:36pm UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/19 "2022-09-02T14:36:53Z")

</div>

Would be happy to see some links, probably others too, put them here? Or PM me if you prefer.

---

<div class="post-metadata">

**Author:** ![lrnv](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lrnv/32/19373_2.png) [@lrnv](https://discourse.julialang.org/u/lrnv)\
**Post date:** [March 1, 2024, 10:57am UTC](https://discourse.julialang.org/t/survival-analysis-in-julia/969/20 "2024-03-01T10:57:49Z")

</div>

@RaphaelS1 What is the current state of SurvivalAnalysis.jl ? It looks like nothing happend since 2 years according to github, and the docs are 404.

Even without the 404, looking at the `docs/src` forlder it does not seem to be well documented. Is there somewhere I can get a getting started guide and a tour of the internals ?

More generally, what would be the go-to interface to build upon for survival analsyis these days ?

[Next page](https://discourse.julialang.org/t/survival-analysis-in-julia/969.md?page=2)
