Survival.jl icon indicating copy to clipboard operation
Survival.jl copied to clipboard

support for stratification

Open vjd opened this issue 5 years ago • 2 comments

Are there are any plans to support stratification for the K-M fit?

vjd avatar Jul 18 '20 19:07 vjd

Not sure if this is what you had in mind but it isn't hard to do this on your own. Suppose you have failure time data and also a variable on whether that thing/person was cool or not.

using DataFrames, Survival, Random
Random.seed!(111)
N = 100
df = DataFrame(cool=rand(Bool,N),time=randexp(N),status=rand(Bool,N))

# create EventTimes
df.evt = EventTime.(df.time,df.status)

# group data
gdf = groupby(df,:cool)

# fit separately for each group
KMs = [ fit(KaplanMeier,g.evt) for g in gdf]

tbeason avatar Aug 13 '20 03:08 tbeason

if you can add this example to the documentation it will help a lot of people.

I myself had to google to come up with this example.

AugustoCL avatar Mar 20 '23 02:03 AugustoCL