Some questions are not about whether something happens, but when. How long before a customer churns? When will a machine fail? Which employees are most likely to leave in the next six months, and what factors accelerate their departure? Cox proportional hazards is the standard method for answering these questions. It models time-to-event data with covariates, telling you exactly which factors speed up or slow down the event — and by how much. Upload a CSV with time, event status, and predictor columns, and get a full survival analysis in under 60 seconds.
What Is Cox Proportional Hazards?
The Cox proportional hazards model, introduced by Sir David Cox in 1972, is a regression model for time-to-event outcomes. Unlike ordinary regression which predicts a number (revenue, score), or logistic regression which predicts a yes/no outcome (churned or not), Cox regression predicts how quickly an event happens while accounting for the fact that some subjects haven't experienced the event yet. Those incomplete observations — customers still subscribed, patients still alive, machines still running — are called censored data, and handling them correctly is what makes survival analysis fundamentally different from standard approaches.
The key output is the hazard ratio. A hazard ratio is a multiplier on the baseline risk of the event happening. A hazard ratio of 2.0 for a variable means that group experiences the event twice as fast as the reference group, all else being equal. A hazard ratio of 0.5 means the event happens half as fast — that factor is protective. For example, if customers on annual plans have a hazard ratio of 0.4 compared to monthly customers, they churn at 40% of the rate. That single number tells you both the direction and the magnitude of the effect, which is why hazard ratios are so widely used in clinical research, reliability engineering, and customer analytics.
The "proportional hazards" assumption means that these ratios stay constant over time. A variable that doubles the hazard does so at month 1 and month 12 alike. The report tests this assumption explicitly and flags any violations, so you will know if a factor's effect changes over the observation period.
When to Use Cox Proportional Hazards
Survival analysis answers a different question than classification or standard regression. Use it when you have time-to-event data and want to understand which factors influence the timing. Here are the most common scenarios.
Customer churn survival. You have subscription data with a start date, an end date (or the customer is still active), and attributes like plan type, usage frequency, company size, or acquisition channel. The Cox model tells you which factors shorten subscription lifetime. Maybe enterprise customers on annual plans with high first-month usage have a hazard ratio of 0.3 — they churn at less than a third the rate of the baseline group. That tells your retention team exactly where to focus.
Clinical trials and treatment effects. Time-to-recovery, time-to-relapse, or overall survival are classic survival endpoints. The Cox model estimates the treatment effect as a hazard ratio while adjusting for patient age, disease stage, and other covariates. A hazard ratio of 0.7 for a new drug means patients on the drug experience the event 30% slower than the control group.
Employee retention and attrition. HR data with hire date, termination date (or still employed), department, role level, salary band, and performance ratings. The model identifies what predicts early departures. If employees in a specific department who were not promoted within 18 months have a hazard ratio of 3.1, that is a clear signal about where attrition concentrates and what might prevent it.
Equipment failure and reliability. Manufacturing and operations teams track time-to-failure for components, vehicles, or infrastructure. The Cox model identifies which operating conditions, materials, or configurations lead to faster failure. A hazard ratio of 1.8 for units operating above a temperature threshold tells engineering exactly what environmental factor to control.
What Data Do You Need?
You need a CSV with three essential elements: a time column, an event indicator column, and one or more predictor columns. The time column records how long each subject was observed — days subscribed, months employed, hours of operation, weeks in a trial. The event indicator is a binary column (typically 1 for "event occurred" and 0 for "censored" — still being observed, dropped out, or the study ended before the event happened). The predictor columns are the factors you want to test: plan type, region, usage level, treatment group, age, or any other attribute.
Censoring is what separates survival analysis from simpler approaches. If a customer has been subscribed for 8 months and is still active, you cannot pretend they churned at month 8 or ignore them entirely. Both approaches bias your results. The Cox model uses that 8-month observation correctly — it knows the customer survived at least 8 months and factors that information into the hazard estimates without assuming anything about when they might eventually churn. This is why survival analysis is the right tool for data where not everyone has experienced the event yet.
For reliable results, you want at least 50 events (not just 50 rows — 50 rows where the event actually occurred). More events mean tighter confidence intervals on your hazard ratios. If you have 500 rows but only 10 events, the model will run but the estimates will be imprecise. The number of predictors should be modest relative to the number of events — a common rule of thumb is at least 10 events per predictor variable.
How to Read the Report
The report is organized into sections that build from summary to detail. Here is what each one tells you and how to use it.
Overview and Preprocessing. The overview card summarizes the dataset: how many subjects, how many events, what the event rate is, and what predictors are included. The preprocessing card shows how the data was prepared — any transformations, factor level assignments, or missing value handling. Check this first to make sure the model used the columns you intended.
Model Performance. This table reports the concordance index (C-index), which measures how well the model discriminates between subjects who experience the event sooner versus later. A C-index of 0.5 is random guessing; 0.7 or above indicates useful discrimination; above 0.8 is strong. The table also shows the log-likelihood, AIC, and overall model significance. If the global p-value is above 0.05, the model as a whole does not significantly predict the event timing — none of the covariates matter enough to distinguish from chance.
Hazard Ratios. This is the centerpiece of the analysis. The hazard ratios plot shows each predictor's estimated hazard ratio with its 95% confidence interval. A ratio above 1.0 means the factor accelerates the event; below 1.0 means it slows the event down. The confidence interval tells you how precisely the ratio is estimated — if it crosses 1.0, that variable is not statistically significant. Look for variables with large ratios and tight confidence intervals — those are the strongest, most reliable predictors.
Coefficient Table. The companion table to the hazard ratios plot. It shows the raw coefficients (log hazard ratios), standard errors, z-statistics, and p-values for each predictor. This is the standard output format used in academic publications and clinical trial reports. The coefficient is the natural log of the hazard ratio — a coefficient of 0.693 corresponds to a hazard ratio of 2.0 (since exp(0.693) = 2.0).
Survival Curves. The Kaplan-Meier-style survival curve shows the probability of "surviving" (not yet experiencing the event) over time, stratified by a key grouping variable. Curves that drop steeply represent groups that experience the event quickly; flat curves represent groups that last longer. The separation between curves is the visual representation of the hazard ratios — wider gaps mean larger differences in event timing.
Cumulative Hazard. The cumulative hazard plot shows accumulated risk over time. While survival curves show the probability of surviving past time t, the cumulative hazard shows total accumulated risk up to time t. Steeper slopes indicate periods of higher event rates. This view is especially useful for spotting time-varying risk — periods where the event rate accelerates or decelerates.
Proportional Hazards Diagnostics. The PH diagnostics card tests the core assumption that hazard ratios remain constant over time. It plots Schoenfeld residuals against time for each covariate. A flat, random scatter means the proportional hazards assumption holds. A clear trend (increasing or decreasing residuals) means the effect of that variable changes over time — the hazard ratio at the beginning of the observation period differs from the hazard ratio at the end. The card also reports the formal statistical test. If the assumption is violated for a specific variable, the model's estimate for that variable is an average effect that may mask important time-varying behavior.
Model Interpretation. The interpretation table translates the statistical results into plain-language findings. It ranks variables by their impact and explains what each hazard ratio means in practical terms. This is where the analysis becomes actionable — instead of "coefficient = 0.47, p = 0.003," you get "this factor increases the event rate by 60%, and the result is statistically significant."
TLDR. The summary card distills the entire analysis into key findings: which variables matter most, what the model's overall predictive power is, and what actions the results suggest. Start here if you want the answer before the methodology.
Understanding Hazard Ratios
Hazard ratios are the most important output of a Cox model, and they are often misunderstood. A hazard ratio is not a probability and it is not a relative risk in the traditional sense. It is a rate multiplier — it tells you how much faster or slower the event happens for one group compared to another, at any given moment in time.
A hazard ratio of 1.0 means no difference from the reference group. A hazard ratio of 2.0 means the event happens twice as fast — if the baseline group has a 5% monthly churn rate at a given point, this group has a 10% rate at that same point. A hazard ratio of 0.5 means the event happens half as fast — this group is protected. The further the ratio is from 1.0 in either direction, the stronger the effect.
For continuous predictors (like age or usage count), the hazard ratio applies per unit increase. A hazard ratio of 1.03 for age means each additional year of age increases the hazard by 3%. That sounds small, but over a 20-year range it compounds: exp(0.03 x 20) = 1.82, meaning the oldest subjects have an 82% higher hazard than the youngest.
Always check the confidence interval. A hazard ratio of 3.0 with a confidence interval of [0.8, 11.2] crosses 1.0 and is not statistically significant — you cannot be confident the variable matters at all. A hazard ratio of 1.4 with a confidence interval of [1.2, 1.6] is both significant and precisely estimated. The interval width tells you how much data supports the estimate.
When to Use Something Else
If you want to compare survival curves between groups without modeling covariates, use the Kaplan-Meier estimator. It is a non-parametric method that plots survival probabilities for each group and tests whether the curves differ (via the log-rank test). It is simpler and requires no assumptions about the functional form of the relationship, but it cannot adjust for confounders or quantify the effect of continuous variables. Kaplan-Meier answers "do these groups survive differently?" while Cox answers "which factors explain the differences, and by how much?"
If your question is simply "will this customer churn or not?" without concern for timing, logistic regression may suffice. Logistic regression predicts a binary outcome (churned vs. retained) but throws away the time dimension entirely. A customer who churned after 1 month and one who churned after 11 months look the same to logistic regression. If timing matters — and it usually does, because a customer who stays 11 months generates far more revenue — survival analysis is the better choice.
For machine-learning-based churn prediction that prioritizes prediction accuracy over interpretability, consider the churn prediction module. It uses ensemble methods to classify at-risk customers and generates risk scores, but it does not produce hazard ratios or survival curves. Choose it when you need a ranked list of who will churn next; choose Cox when you need to understand why and when they churn.
If the proportional hazards assumption is badly violated — meaning the effect of a variable changes dramatically over time — parametric survival models like the Weibull or accelerated failure time (AFT) model may be more appropriate. The PH diagnostics card in the report will tell you if this is a concern.
The R Code Behind the Analysis
Every report includes the exact R code used to produce the results — reproducible, auditable, and citable. This is not AI-generated code that changes every run. The same data produces the same analysis every time.
The analysis uses coxph() from the survival package — the standard implementation of Cox proportional hazards in R, used in thousands of peer-reviewed publications. Survival curves are generated with survfit(), and the proportional hazards assumption is tested with cox.zph(). Hazard ratios are extracted directly from the model coefficients via exponentiation. Every function is from well-established, CRAN-hosted packages — no custom implementations, no black boxes. The full code is visible in the code tab of your report, so you or a statistician can verify exactly what was done and reproduce it independently.