Survival analysis
stat kmstat kmstat logrankstat coxstat coxstat survregstat survregstat coxstat weibullstat weibull

stat km <json_times> <json_events>


Description

    Kaplan-Meier survival curve: for each time, the number at risk, the events, the censored, the survival, its standard error (Greenwood) and its 95 % interval (log-log); the median survival

Parameters

    json_times:   The times (follow-up durations) - String - required
    json_events:   1 = event, 0 = censored - String - required
admin
stat km "[9, 13, 13, 18, 23, 28, 31, 34, 45, 48, 161]" "[1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0]"
mentdb
{"n": 11, "events": 7, "median": 31, "table": [{"time": 9, "at_risk": 11, "events": 1, "censored": 0, "survival": 0.9090909090909091, "se": 0.08667841720414475, "lower": 0.5080802057699296, "upper": 0.9866738226678231}, {"time": 13, "at_risk": 10, "events": 1, "censored": 1, "survival": 0.8181818181818181, "se": 0.11629129983033294, "lower": 0.44742861468218115, "upper": 0.9511622285824917}, {"time": 18, "at_risk": 8, "events": 1, "censored": 0, "survival": 0.7159090909090908, "se": 0.13966497055722782, "lower": 0.3501903859079383, "upper": 0.8990239741910535}, {"time": 23, "at_risk": 7, "events": 1, "censored": 0, "survival": 0.6136363636363636, "se": 0.15263233102731202, "lower": 0.265752040001286, "upper": 0.8352992432502215}, {"time": 28, "at_risk": 6, "events": 0, "censored": 1, "survival": 0.6136363636363636, "se": 0.15263233102731202, "lower": 0.265752040001286, "upper": 0.8352992432502215}, {"time": 31, "at_risk": 5, "events": 1, "censored": 0, "survival": 0.49090909090909096, "se": 0.16419326722113584, "lower": 0.16733090977685078, "upper": 0.7533997903708114}, {"time": 34, "at_risk": 4, "events": 1, "censored": 0, "survival": 0.3681818181818182, "se": 0.16266888582709482, "lower": 0.09282957493698518, "upper": 0.6570408323981639}, {"time": 45, "at_risk": 3, "events": 0, "censored": 1, "survival": 0.3681818181818182, "se": 0.16266888582709482, "lower": 0.09282957493698518, "upper": 0.6570408323981639}, {"time": 48, "at_risk": 2, "events": 1, "censored": 0, "survival": 0.1840909090909091, "se": 0.15349274578629368, "lower": 0.01173848012318958, "upper": 0.5250148427266416}, {"time": 161, "at_risk": 1, "events": 0, "censored": 1, "survival": 0.1840909090909091, "se": 0.15349274578629368, "lower": 0.01173848012318958, "upper": 0.5250148427266416}]}

stat km <json_times> <json_events> <json_groups>


Description

    Kaplan-Meier curves of several groups and the log-rank test

Parameters

    json_times:   The times - String - required
    json_events:   1 = event, 0 = censored - String - required
    json_groups:   The group of each subject - String - required
admin
stat km "[9, 13, 13, 18, 23, 28, 31, 34, 45, 48, 161, 5, 5, 8, 8, 12, 16, 23, 27, 30, 33, 43, 45]" "[1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]" "[\"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\"]"
mentdb
{"groups": {"maintained": {"n": 11, "events": 7, "median": 31, "table": [{"time": 9, "at_risk": 11, "events": 1, "censored": 0, "survival": 0.9090909090909091, "se": 0.08667841720414475, "lower": 0.5080802057699296, "upper": 0.9866738226678231}, {"time": 13, "at_risk": 10, "events": 1, "censored": 1, "survival": 0.8181818181818181, "se": 0.11629129983033294, "lower": 0.44742861468218115, "upper": 0.9511622285824917}, {"time": 18, "at_risk": 8, "events": 1, "censored": 0, "survival": 0.7159090909090908, "se": 0.13966497055722782, "lower": 0.3501903859079383, "upper": 0.8990239741910535}, {"time": 23, "at_risk": 7, "events": 1, "censored": 0, "survival": 0.6136363636363636, "se": 0.15263233102731202, "lower": 0.265752040001286, "upper": 0.8352992432502215}, {"time": 28, "at_risk": 6, "events": 0, "censored": 1, "survival": 0.6136363636363636, "se": 0.15263233102731202, "lower": 0.265752040001286, "upper": 0.8352992432502215}, {"time": 31, "at_risk": 5, "events": 1, "censored": 0, "survival": 0.49090909090909096, "se": 0.16419326722113584, "lower": 0.16733090977685078, "upper": 0.7533997903708114}, {"time": 34, "at_risk": 4, "events": 1, "censored": 0, "survival": 0.3681818181818182, "se": 0.16266888582709482, "lower": 0.09282957493698518, "upper": 0.6570408323981639}, {"time": 45, "at_risk": 3, "events": 0, "censored": 1, "survival": 0.3681818181818182, "se": 0.16266888582709482, "lower": 0.09282957493698518, "upper": 0.6570408323981639}, {"time": 48, "at_risk": 2, "events": 1, "censored": 0, "survival": 0.1840909090909091, "se": 0.15349274578629368, "lower": 0.01173848012318958, "upper": 0.5250148427266416}, {"time": 161, "at_risk": 1, "events": 0, "censored": 1, "survival": 0.1840909090909091, "se": 0.15349274578629368, "lower": 0.01173848012318958, "upper": 0.5250148427266416}]}, "not": {"n": 12, "events": 11, "median": 23, "table": [{"time": 5, "at_risk": 12, "events": 2, "censored": 0, "survival": 0.8333333333333334, "se": 0.1075828707279838, "lower": 0.4817149421953787, "upper": 0.955509365728065}, {"time": 8, "at_risk": 10, "events": 2, "censored": 0, "survival": 0.6666666666666667, "se": 0.13608276348795437, "lower": 0.3370189325414019, "upper": 0.8597117990844398}, {"time": 12, "at_risk": 8, "events": 1, "censored": 0, "survival": 0.5833333333333334, "se": 0.14231876063832777, "lower": 0.2701389240854973, "upper": 0.8009401923333869}, {"time": 16, "at_risk": 7, "events": 0, "censored": 1, "survival": 0.5833333333333334, "se": 0.14231876063832777, "lower": 0.2701389240854973, "upper": 0.8009401923333869}, {"time": 23, "at_risk": 6, "events": 1, "censored": 0, "survival": 0.48611111111111116, "se": 0.14813006255348293, "lower": 0.1918766196187282, "upper": 0.7296715697794854}, {"time": 27, "at_risk": 5, "events": 1, "censored": 0, "survival": 0.38888888888888895, "se": 0.1469861839480328, "lower": 0.1262720121953936, "upper": 0.6498174082893151}, {"time": 30, "at_risk": 4, "events": 1, "censored": 0, "survival": 0.29166666666666674, "se": 0.13871516913498738, "lower": 0.07240160890777181, "upper": 0.5608860526714093}, {"time": 33, "at_risk": 3, "events": 1, "censored": 0, "survival": 0.1944444444444445, "se": 0.12187450538044617, "lower": 0.031198642931211912, "upper": 0.461429476238114}, {"time": 43, "at_risk": 2, "events": 1, "censored": 0, "survival": 0.09722222222222225, "se": 0.09186636496752053, "lower": 0.005746305695863835, "upper": 0.3489038611107498}, {"time": 45, "at_risk": 1, "events": 1, "censored": 0, "survival": 0, "se": "NaN", "lower": "NaN", "upper": "NaN"}]}}, "logrank": {"chi2": 3.3963886989775984, "df": 1, "p_value": 0.06533932204050386, "groups": [{"group": "maintained", "observed": 7, "expected": 10.689335992300723}, {"group": "not", "observed": 11, "expected": 7.310664007699275}]}}
Used in use cases (1 recipe)

    Epidemiologist › Survival in a clinical trial
Often used with

    stat cox

stat logrank <json_times> <json_events> <json_groups>


Description

    Log-rank (Mantel-Cox) test: are the survival curves of the groups different? chi2, degrees of freedom, p-value, observed and expected events of each group

Parameters

    json_times:   The times - String - required
    json_events:   1 = event, 0 = censored - String - required
    json_groups:   The groups - String - required
admin
stat logrank "[9, 13, 13, 18, 23, 28, 31, 34, 45, 48, 161, 5, 5, 8, 8, 12, 16, 23, 27, 30, 33, 43, 45]" "[1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]" "[\"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"maintained\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\", \"not\"]"
mentdb
{"chi2": 3.3963886989775984, "df": 1, "p_value": 0.06533932204050386, "groups": [{"group": "maintained", "observed": 7, "expected": 10.689335992300723}, {"group": "not", "observed": 11, "expected": 7.310664007699275}]}

stat cox <json_X> <json_times> <json_events>


Description

    Cox proportional hazards model: coefficient, standard error, z, p-value and hazard ratio with its 95 % interval for each covariate, likelihood ratio test, concordance (C index)

Parameters

    json_X:   The covariates (rows) - String - required
    json_times:   The times - String - required
    json_events:   1 = event, 0 = censored - String - required
admin
stat cox "[[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]" "[9, 13, 13, 18, 23, 28, 31, 34, 45, 48, 161, 5, 5, 8, 8, 12, 16, 23, 27, 30, 33, 43, 45]" "[1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]"
mentdb
{"n": 23, "events": 18, "coefficients": [{"feature": "x0", "coef": 0.9155325750147174, "se": 0.5119342751720054, "z": 1.7883791326671896, "p_value": 0.07371486063904564, "hazard_ratio": 2.4981053261721406, "hr_lower": 0.915907257436408, "hr_upper": 6.813495766063302}], "log_likelihood": -41.03261559645837, "null_log_likelihood": -42.72483926276023, "lr_test": 3.384447332603713, "lr_p_value": 0.06581424016233806, "concordance": 0.6177884615384616, "iterations": 3, "ties": "efron"}

stat cox <json_X> <json_times> <json_events> <json_params>


Description

    Cox model with parameters: ties (efron or breslow), max_iter, tol, level (of the intervals)

Parameters

    json_X:   The covariates - String - required
    json_times:   The times - String - required
    json_events:   1 = event, 0 = censored - String - required
    json_params:   The parameters - String - required
admin
stat cox "[[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]" "[9, 13, 13, 18, 23, 28, 31, 34, 45, 48, 161, 5, 5, 8, 8, 12, 16, 23, 27, 30, 33, 43, 45]" "[1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]" "{\"ties\": \"breslow\", \"level\": 0.9}"
mentdb
{"n": 23, "events": 18, "coefficients": [{"feature": "x0", "coef": 0.9042197236857006, "se": 0.5122479073041513, "z": 1.765199448923884, "p_value": 0.07753025120861778, "hazard_ratio": 2.4700038854262183, "hr_lower": 1.0635867211128747, "hr_upper": 5.736174655919898}], "log_likelihood": -41.25011435006887, "null_log_likelihood": -42.89812389717403, "lr_test": 3.2960190942103225, "lr_p_value": 0.06944800054678268, "concordance": 0.6177884615384616, "iterations": 3, "ties": "breslow"}
Used in use cases (2 recipes)

    Epidemiologist › Survival in a clinical trial
    Epidemiologist › A treatment received during the follow-up: Cox model with a time-varying covariate
Often used with

    stat km

stat survreg <json_X> <json_times> <json_events> <distribution>


Description

    Parametric survival model (accelerated failure time): weibull, lognormal, loglogistic or exponential, by maximum likelihood; coefficients, time ratios (and hazard ratios for weibull and exponential), scale (Weibull shape = 1 / scale), likelihood ratio test, AIC. Checked against R survreg

Parameters

    json_X:   The covariates - String - required
    json_times:   The times (> 0) - String - required
    json_events:   1 = event, 0 = censored - String - required
    distribution:   weibull, lognormal, loglogistic or exponential - String - required
admin
stat survreg "[[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]" "[9, 13, 13, 18, 23, 28, 31, 34, 45, 48, 161, 5, 5, 8, 8, 12, 16, 23, 27, 30, 33, 43, 45]" "[1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]" "weibull"
mentdb
{"distribution": "weibull", "n": 23, "events": 18, "coefficients": [{"term": "intercept", "estimate": 4.109055139603286, "se": 0.2998897156573543, "z": 13.7018874775225, "p_value": 0}, {"term": "x0", "estimate": -0.9293416973897514, "se": 0.38250195097276685, "z": -2.4296391038693503, "p_value": 0.015113863945892758, "time_ratio": 0.39481353162014204, "hazard_ratio": 3.238021089549223}], "scale": 0.7909544359920174, "shape": 1.2642953304203888, "scale_lower": 0.5577588658053956, "scale_upper": 1.1216476477018082, "log_likelihood": -80.52164520340277, "aic": 167.04329040680554, "lr_test": 5.314048058813881, "lr_p_value": 0.021154148339265433}

stat survreg <json_X> <json_times> <json_events> <distribution> <json_params>


Description

    Parametric survival model with parameters: level, predict (rows of covariates: their median survival time)

Parameters

    json_X:   The covariates - String - required
    json_times:   The times - String - required
    json_events:   1 = event, 0 = censored - String - required
    distribution:   The distribution - String - required
    json_params:   The parameters - String - required
admin
stat survreg "[[0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [0], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1], [1]]" "[9, 13, 13, 18, 23, 28, 31, 34, 45, 48, 161, 5, 5, 8, 8, 12, 16, 23, 27, 30, 33, 43, 45]" "[1, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1, 1, 1, 1, 0, 1, 1, 1, 1, 1, 1]" "lognormal" "{\"predict\": [[0], [1]]}"
mentdb
{"distribution": "lognormal", "n": 23, "events": 18, "coefficients": [{"term": "intercept", "estimate": 3.578862032287345, "se": 0.28468628203416585, "z": 12.571248627490373, "p_value": 0}, {"term": "x0", "estimate": -0.7244730888990573, "se": 0.3803167307143538, "z": -1.9049203739690077, "p_value": 0.056790422413420805, "time_ratio": 0.484579832191815}], "scale": 0.8647019350714125, "scale_lower": 0.6202727856581065, "scale_upper": 1.205452590867628, "log_likelihood": -78.92761245032302, "aic": 163.85522490064605, "lr_test": 3.4890845260065078, "lr_p_value": 0.06177473777002451, "median_times": [35.832741134620775, 17.363823685987285]}
Used in use cases (1 recipe)

    Mechanical & civil engineer › Weibull life of bearings

stat cox <json_X> <json_times> <json_events> <json_params>


Description

    Extended Cox model (as R coxph + survfit) when one of these parameters is given: strata (one baseline hazard per stratum), start (entry times: rows (start, stop] for the covariates that change with time or a late entry), predict (rows of covariates: survival curves, median, survival at times), predict_strata, times

Parameters

    json_X:   The covariates - String - required
    json_times:   The times (stop) - String - required
    json_events:   The events - String - required
    json_params:   The parameters - String - required
admin
stat cox "[[0], [1], [0], [0], [1], [0], [1], [0], [0], [1], [1], [1], [0], [0], [1], [1], [1], [0], [0], [0], [0], [1], [1], [1]]" "[4.49, 4.72, 9.16, 2.13, 5.63, 10.07, 11.39, 1.74, 1.79, 11.91, 13.93, 10.35, 5.07, 6.83, 13.41, 8.24, 8.48, 11.5, 9.7, 7.59, 6.26, 4.7, 1.03, 4.22]" "[1, 0, 0, 1, 1, 1, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 0, 0, 1, 0, 1, 0, 1, 0]" "{\"strata\": [\"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\", \"B\", \"A\"], \"predict\": [[0], [1]], \"predict_strata\": [\"A\", \"A\"], \"times\": [5, 10]}"
mentdb
{"n": 24, "events": 11, "ties": "efron", "strata": 2, "form": "right censored", "coefficients": [{"feature": "x0", "coef": -1.5893879626167553, "se": 0.8023487496319396, "z": -1.9809190995135884, "p_value": 0.04760034681529546, "hazard_ratio": 0.20405046003401195, "hr_lower": 0.04234255734291549, "hr_upper": 0.9833272445708403}], "log_partial_likelihood": -18.321769849388318, "lr_test": 4.980539301617419, "lr_p_value": 0.025633991023644387, "iterations": 4, "predictions": [{"risk_score": 1, "median": 10.07, "times": [5, 10], "survival": [0.7414984349924535, 0.5969626182734827], "curve": [[1.74, 0.8707314593388465], [2.13, 0.7414984349924535], [6.83, 0.5969626182734827], [10.07, 0.3940940188444041]]}, {"risk_score": 0.20405046003401195, "median": null, "times": [5, 10], "survival": [0.940797022961391, 0.9000816548100741], "curve": [[1.74, 0.9721501569879587], [2.13, 0.940797022961391], [6.83, 0.9000816548100741], [10.07, 0.8269551611820606]]}]}
A covariate that changes: the second row of the subject starts at 4
admin
stat cox "[[0], [0], [1], [0], [1], [0], [1], [1], [0]]" "[4, 9, 6, 3, 8, 12, 5, 10, 7]" "[0, 1, 1, 1, 1, 0, 1, 1, 0]" "{\"start\": [0, 4, 0, 0, 2, 0, 0, 5, 0]}"
mentdb
{"n": 9, "events": 6, "ties": "efron", "strata": 1, "form": "counting process (start, stop]", "coefficients": [{"feature": "x0", "coef": 0.8664291350477776, "se": 0.8730889572975914, "z": 0.9923721148983176, "p_value": 0.32101603647273147, "hazard_ratio": 2.378402716957342, "hr_lower": 0.4296459521436774, "hr_upper": 13.166188243613156}], "log_partial_likelihood": -8.181063308417317, "lr_test": 1.0528392188841025, "lr_p_value": 0.3048540942878619, "iterations": 3}
Used in use cases (2 recipes)

    Epidemiologist › Survival in a clinical trial
    Epidemiologist › A treatment received during the follow-up: Cox model with a time-varying covariate
Often used with

    stat km

stat weibull <json_times> <json_status>


Description

    Weibull reliability analysis of failures with suspensions: shape (beta: < 1 infant mortality, 1 random, > 1 wear-out) and scale (eta) by maximum likelihood with intervals, B1, B10 and B50 lives, MTTF, median rank plotting points

Parameters

    json_times:   The times (hours, cycles, km) - String - required
    json_status:   1 = failure, 0 = suspension - String - required
admin
stat weibull "[150, 230, 310, 380, 420, 500, 560, 640, 700, 800, 520, 600]" "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]"
mentdb
{"n": 12, "failures": 10, "suspensions": 2, "shape": 2.6666314620137896, "shape_lower": 1.5923300670265572, "shape_upper": 4.465734524174632, "scale": 575.2112725830922, "scale_lower": 454.9583508014659, "scale_upper": 727.2490053733383, "log_likelihood": -68.97569633762355, "mttf": 511.31288426697716, "failure_mode": "wear-out (beta > 1)", "b_lives": [{"percent": 1, "life": 102.47907893558428, "lower": 39.644134691661364, "upper": 264.9058101826767}, {"percent": 10, "life": 247.3584539582148, "lower": 146.88622086092306, "upper": 416.55510221432877}, {"percent": 50, "life": 501.34437699008953, "lower": 388.92280876724163, "upper": 646.2623910802927}], "plot_points": [[150, 0.0564516129032258], [230, 0.13709677419354838], [310, 0.21774193548387097], [380, 0.29838709677419356], [420, 0.3790322580645161], [500, 0.4596774193548387], [560, 0.5537634408602151], [640, 0.6713709677419354], [700, 0.7889784946236559], [800, 0.9065860215053764]]}

stat weibull <json_times> <json_status> <json_params>


Description

    Weibull analysis with parameters: b_lives (percentages), times (reliability and hazard rate at these times), level

Parameters

    json_times:   The times - String - required
    json_status:   The status - String - required
    json_params:   The parameters - String - required
admin
stat weibull "[150, 230, 310, 380, 420, 500, 560, 640, 700, 800, 520, 600]" "[1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 0, 0]" "{\"times\": [200, 400], \"b_lives\": [5]}"
mentdb
{"n": 12, "failures": 10, "suspensions": 2, "shape": 2.6666314620137896, "shape_lower": 1.5923300670265572, "shape_upper": 4.465734524174632, "scale": 575.2112725830922, "scale_lower": 454.9583508014659, "scale_upper": 727.2490053733383, "log_likelihood": -68.97569633762355, "mttf": 511.31288426697716, "failure_mode": "wear-out (beta > 1)", "b_lives": [{"percent": 5, "life": 188.8398839045309, "lower": 98.70787854641524, "upper": 361.27310482423275}], "reliability": [{"time": 200, "reliability": 0.9419716762434713, "hazard_rate": 7.970571111818951E-4}, {"time": 400, "reliability": 0.6841551649452673, "hazard_rate": 0.0025304368450495755}], "plot_points": [[150, 0.0564516129032258], [230, 0.13709677419354838], [310, 0.21774193548387097], [380, 0.29838709677419356], [420, 0.3790322580645161], [500, 0.4596774193548387], [560, 0.5537634408602151], [640, 0.6713709677419354], [700, 0.7889784946236559], [800, 0.9065860215053764]]}
Used in use cases (1 recipe)

    Aeronautical engineer › Bearing failures: Weibull analysis with units still running