Add surv Verb to Estimate a Survival Curve (#1788)

Add a surv verb to estimate a survival curve using Kaplan-Meier.  It
requires duration and status (event or censored) columns, and outputs
each distinct duration and corresponding probability of survival.
This commit is contained in:
Christian G. Warden 2025-05-15 17:17:08 -05:00 committed by GitHub
parent 35c7eeb977
commit df73ad8ec0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 216 additions and 4 deletions

View file

@ -1261,6 +1261,16 @@ Options:
--transpose Show output with field names as column names..
-h|--help Show this message.
================================================================
surv
Usage: mlr surv -d {duration-field} -s {status-field}
Estimate Kaplan-Meier survival curve (right-censored).
Options:
-d {field} Name of duration field (time-to-event or censoring).
-s {field} Name of status field (0=censored, 1=event).
-h, --help Show this message.
================================================================
tac
Usage: mlr tac [options]

View file

@ -0,0 +1 @@
mlr --csv --from test/input/surv.csv surv -d duration -s status

View file

View file

@ -0,0 +1,4 @@
time,survival
1.00000000,0.80000000
3.00000000,0.53333333
5.00000000,0.00000000

6
test/input/surv.csv Normal file
View file

@ -0,0 +1,6 @@
duration,status
1,1
2,0
3,1
4,0
5,1
1 duration status
2 1 1
3 2 0
4 3 1
5 4 0
6 5 1