# Cox proportional hazards (/docs/analyses/cox-proportional-hazards)



## When to use it [#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](/docs/analyses/kaplan-meier) plus log-rank.

## Assumptions [#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 [#running-it-in-tensr]

<Steps>
  <Step>
    Analyze → Survival → Cox Proportional Hazards. In chat: “Cox model of weeks on hours.”
  </Step>

  <Step>
    Duration and event are the same columns as Kaplan–Meier. Covariates need at least one numeric column.
  </Step>
</Steps>

## Options [#options]

<TypeTable
  type="{
  duration_column: {
    type: 'string',
    description: 'Positive time until the event or censoring.',
  },
  event_column: {
    type: 'string',
    description: '1 = event, 0 = censored. true / yes / y / event also count as 1.',
  },
  covariates: {
    type: 'string[]',
    description: 'Numeric predictors. At least one. Categorical columns are not dummy-coded.',
  },
  decimal_places: {
    type: '0–6',
    description: 'Report output. Decimal places.',
    default: '3',
  },
  apa_format: {
    type: 'boolean',
    description: 'Report output. APA-style p-values, including the coefficient table.',
    default: 'true',
  },
  include_charts: {
    type: 'boolean',
    description: 'Report output. Draws the baseline cumulative hazard as a step function.',
    default: 'true',
  },
}"
/>

## Reading the output [#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.

| Covariate |   Coef | Hazard ratio | p-value |
| --------- | -----: | -----------: | ------: |
| hours     | 0.3633 |       1.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) [#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 [#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.

## Related [#related]

Two groups and no covariate: [Kaplan–Meier](/docs/analyses/kaplan-meier). Cumulative hazard without covariates: [Nelson–Aalen](/docs/analyses/nelson-aalen).
