Skip to contents

Test the proportional hazards assumption for fitted Cox proportional hazards models using Schoenfeld residuals.

Usage

check_ph(
  model,
  transform = c("km", "rank", "identity"),
  alpha = 0.05,
  format = c("flextable", "gt", "tibble")
)

Arguments

model

A fitted coxph model or a cox_reg() object.

transform

Time transformation passed to survival::cox.zph(). One of "km", "rank", or "identity".

alpha

Significance level used for the simple interpretation column.

format

Output format. One of "flextable" (default), "gt", or "tibble".

Value

A tibble, gt_tbl, or flextable with Schoenfeld residual proportional hazards tests. The table contains:

Model

Model name. For a direct coxph object, this is "cox_model".

Term

Model term or "GLOBAL".

Chi.square

Chi-square statistic.

df

Degrees of freedom.

p.value

Test p-value.

Interpretation

Simple screening interpretation using alpha.

Details

check_ph() is a diagnostic aid for Cox models. A small p-value suggests possible evidence against the proportional hazards assumption for a term or for the global model test. This should be interpreted with plots, clinical knowledge, follow-up patterns, and modelling purpose.

The returned table retains the underlying cox.zph diagnostics. Use plot() to draw scaled Schoenfeld residual plots. When several models were checked, select one by name or position with the model argument; use term to draw a single model term.

Examples

lung_data <- data_lungcancer
lung_data$trt <- factor(lung_data$trt, levels = c(1, 2),
                        labels = c("Standard", "Test"))

cox_fit <- cox_reg(
  data = lung_data,
  time = time,
  event = status,
  exposures = c(trt, celltype, age)
)

check_ph(cox_fit)
Proportional hazards check

Model

Term

Test

Chi-square

df

p-value

Interpretation

trt

trt

Term

3.54

1

0.060

No evidence of PH violation

trt

GLOBAL

Global

3.54

1

0.060

No evidence of PH violation

celltype

celltype

Term

8.87

3

0.031

Possible PH violation

celltype

GLOBAL

Global

8.87

3

0.031

Possible PH violation

age

age

Term

1.67

1

0.196

No evidence of PH violation

age

GLOBAL

Global

1.67

1

0.196

No evidence of PH violation

Screening aid only. Small p-values suggest possible non-proportional hazards; interpret with Schoenfeld residual plots, follow-up pattern, clinical context, and model purpose. alpha = 0.05; transform = km.

check_ph(cox_fit, format = tibble) #> # A tibble: 6 × 7 #> Model Term Test Chi.square df p.value Interpretation #> <chr> <chr> <chr> <dbl> <dbl> <dbl> <chr> #> 1 trt trt Term 3.54 1 0.0600 No evidence of PH violation #> 2 trt GLOBAL Global 3.54 1 0.0600 No evidence of PH violation #> 3 celltype celltype Term 8.87 3 0.0310 Possible PH violation #> 4 celltype GLOBAL Global 8.87 3 0.0310 Possible PH violation #> 5 age age Term 1.67 1 0.196 No evidence of PH violation #> 6 age GLOBAL Global 1.67 1 0.196 No evidence of PH violation ph <- check_ph(cox_fit) plot(ph, model = "trt")