Cox survival models
Assess associations between clinical variables and survival using Cox models, including covariate-adjusted effects, interactions, and adjusted survival curves.
Assess associations between clinical variables and survival using Cox models, including covariate-adjusted effects, interactions, and adjusted survival curves.
Prognostic subgroup survival
Description
Analysis summary
Displays the prognostic impact of each subgroup level on survival using hazard ratios and confidence intervals estimated from Cox proportional hazards models fit across the cohort. For each subgroup variable, non-reference levels are compared against a designated reference level (hazard ratio = 1). The tool can also generate covariate-adjusted survival curves by group.
Computation
Fits Cox proportional-hazards models via the lifelines library, on one row per patient — rows are deduplicated to one per patient and patients missing any model input are dropped. Multivariate (default): one model with all subgroup variables plus adjustment covariates; univariate: one model per subgroup variable, each including the covariates. Each categorical subgroup level yields a hazard ratio against its variable's reference level, with a 95% confidence interval and p-value; a continuous subgroup variable yields a per-unit hazard ratio. The reference level's row is hazard ratio 1 by definition, and the adjustment variables get estimate rows too (hidden by default). Subgroup levels with fewer than 5 patients or 3 events are excluded from the display. Setting the analysis's plot to kaplan_meier instead fits one Cox model in which the first subgroup variable defines the displayed groups (the remaining subgroup variables and the adjustment covariates adjust the model) and predicts each group's survival curve, holding all other covariates at their mean (numeric) or mode (categorical): confidence bands come from coefficient uncertainty via the delta method on the log cumulative hazard, over a horizon trimmed to the configured percentile of observed follow-up.
When to use
Use to assess how clinical features (stage, gender, etc.) influence outcome on their own — the 'prognostic effect(s) of one or more clinical variables on survival' — and for covariate-adjusted survival curves when the user asks to 'adjust for' covariates in a KM-style plot. For the effect of a treatment or biomarker compared across subgroups, use the interaction mode; for unadjusted Kaplan–Meier curves use kaplan_meier_analysis.
Caveats
Cox models assume proportional hazards, and non-convergent runs raise an error rather than outputting approximations. Listwise deletion across covariates may substantially reduce the analyzed sample relative to the initial cohort. Additionally, confidence bands on adjusted survival curves reflect coefficient uncertainty only—excluding baseline hazard variance—so intervals may underestimate true uncertainty at later follow-up times when numbers at risk are small.
lifelines — the survival-analysis Python library this analysis fits its Cox models with. Documentation: https://lifelines.readthedocs.io/en/latest/ — paper: Davidson-Pilon, C. (2019). lifelines: survival analysis in Python. Journal of Open Source Software, 4(40), 1317. https://doi.org/10.21105/joss.01317.
Example questions
Input columns
Visualizations
forestHow to read: One row per subgroup level (or per unit for continuous variables): the point is the hazard ratio, the whiskers its 95% confidence interval, and the dashed reference line sits at 1 (no effect). Reference-level rows sit at hazard ratio 1 with no estimate — hide them with show_reference; adjustment-variable rows are hidden unless show_adjust_vars. Rows are sorted by hazard ratio within each variable group by default (sort_by); the x-axis is log-scaled by default, and rows with non-positive estimates are dropped on that scale. Hover gives the p-value; subgroup levels with fewer than 5 patients or 3 events are excluded.kaplan_meierHow to read: Cox-adjusted survival curves: one curve per level of the displayed group variable, each adjusted for the model's other covariates held at their mean (numeric) or mode (categorical). Shaded bands are confidence intervals (toggle with show_ci). The x-axis is time in the selected unit, ending at the configured follow-up percentile; the y-axis is the outcome label (e.g. Overall Survival). These are model-adjusted curves, not Kaplan–Meier estimates of the raw data.
Example analysis 1
Name — Overall Survival Subgroup Effects by Gender and Stage — Bladder Cancer (TCGA)
Analysis parameters
Visualization — forest

Output table
Example analysis 2
Name — Cox-Adjusted Overall Survival by Gender (Adjusted for Age and Smoking Status)
Analysis parameters
Visualization — kaplan_meier

Output table
Interaction (effect of a variable across subgroups)
Description
Analysis summary
Quantifies how the effect of one variable (e.g. a treatment, a biomarker) on survival changes across subgroups defined by other variables (e.g. stage, gender): one hazard ratio per subgroup level — useful for finding subgroups where the treatment helps more or less than overall.
Computation
Fits a Cox model with the effect variable, the subgroup variables, and their interaction terms, via the lifelines library; adjustment covariates join the model as pure covariates with no estimate rows. The effect variable must be binary or two-level categorical; its two levels are ordered alphabetically and the model contrasts the second against the first. Each subgroup level shows the hazard ratio of the effect variable within that subgroup: the reference subgroup shows the model's base effect, the other levels add their interaction term, with the standard error combining the base and interaction coefficients' variance and covariance. An 'Overall' row gives the effect across the whole cohort. Multivariate (one model with all subgroup variables) vs univariate (one model per subgroup variable) behaves as in prognostic mode, and subgroup levels with fewer than 5 patients or 3 events are excluded from the display.
When to use
Use to test whether the effect of a treatment, procedure or biomarker differs across subgroups (stage, gender, …) — the interaction-effect question. For subgroup effects with no intervention variable, use the prognostic mode (effect_var unset).
Caveats
Interaction effects are estimated from the same data as the overall model — sparse subgroups give unstable interaction estimates, and levels with fewer than 5 patients or 3 events are excluded from the display. The two-level requirement makes the effect variable a contrast, not a multi-category factor.
lifelines — the survival-analysis Python library this analysis fits its Cox models with. Documentation: https://lifelines.readthedocs.io/en/latest/ — paper: Davidson-Pilon, C. (2019). lifelines: survival analysis in Python. Journal of Open Source Software, 4(40), 1317. https://doi.org/10.21105/joss.01317.
Example questions
Input columns
Visualizations
forestHow to read: The plot displays one row per subgroup level, headed by an 'Overall' row showing the cohort-wide effect. Points represent hazard ratios for the effect variable within each stratum, whiskers show 95% confidence intervals, and the dashed vertical line marks no effect (HR = 1). A confidence interval crossing 1 indicates that the effect within that specific subgroup is not statistically significant. The x-axis is log-scaled by default. Hovering over a point displays the exact p-value; levels with fewer than 5 patients or 3 events are excluded.
Last updated
Was this helpful?