Analyses

Cox proportional hazards

Hazard ratios for numeric covariates on time-to-event data with censoring.

Edit on GitHub

When to use it

Use Cox when you have duration, an event indicator, and at least one numeric covariate that should change the hazard. “Does each extra hour of study change the hazard of dropping the course?” is the shape of the question. Two named arms with no covariate is Kaplan–Meier plus log-rank.

Assumptions

Duration must be positive and numeric. The event column is 1 for the event and 0 for censored; true, yes, y, and event also count as 1. Covariates are coerced to numeric; a categorical column becomes missing and those rows drop. After dropping missing values you need more rows than covariates plus two.

The model assumes proportional hazards. Tensr does not run a Schoenfeld or other proportional-hazards test. The dialog only offers numeric covariates.

The baseline chart is a step function of the fitted baseline cumulative hazard, from the origin (0, 0), matching Kaplan–Meier.

Running it in Tensr

Analyze → Survival → Cox Proportional Hazards. In chat: “Cox model of weeks on hours.”
Duration and event are the same columns as Kaplan–Meier. Covariates need at least one numeric column.

Options

Prop

Type

Reading the output

The same 80 people. Hours is a numeric covariate with a moderate link to the hazard. Arm is not in this model.

CovariateCoefHazard ratiop-value
hours0.36331.4380.012

Hours is the only covariate. Coef = 0.3633, hazard ratio = 1.4380, p = .012. Concordance = 0.561 on 80 people and 58 events. The slope is moderate. Concordance still sits near chance, so hours sorts the times only a little.

Reporting (APA 7)

A Cox model of weeks on hours (N = 80, 58 events) gave a hazard ratio of 1.4380 per hour, p = .012, concordance = 0.561.

Coming from SPSS

SPSS is Analyze → Survival → Cox Regression. Tensr’s Analyze menu has Survival → Cox Proportional Hazards. The path string stored for this item is Analyze → Survival → Cox PH.

SPSS lets you enter categorical covariates and offers a proportional-hazards plot. Tensr takes numeric covariates only and does not test proportional hazards.

Two groups and no covariate: Kaplan–Meier. Cumulative hazard without covariates: Nelson–Aalen.