zph_phregr: Assess Proportional Hazards Assumption Based on Scaled...

View source: R/zph_phregr.R

zph_phregrR Documentation

Assess Proportional Hazards Assumption Based on Scaled Schoenfeld Residuals

Description

Obtains the scaled Schoenfeld residuals and tests the proportional hazards assumption using a score test for the interaction between each covariate and a transformed time variable.

Usage

zph_phregr(object, transform = "km")

Arguments

object

The output from the phregr call.

transform

A character string indicating how survival times should be transformed before the test is performed. Supported values include "identity", "log", "rank", and "km" (default).

Details

This corresponds to the cox.zph function from the survival package with terms = FALSE and global = TRUE.

Value

A list with the following components:

  • table A matrix with one row for each parameter and a final row for the global test. The columns contain the score test for adding the time-dependent term, the degrees of freedom, and the two-sided p-value.

  • x The transformed time values.

  • time The original (untransformed) event times, with tied event times repeated.

  • strata The stratum index for each event.

  • y The matrix of scaled Schoenfeld residuals, with one column for each parameter and one row for each event. Column names correspond to the parameter names.

  • var An approximate covariance matrix of the scaled Schoenfeld residuals, used to construct an approximate standard error band for plots.

  • transform the transformation applied to the time values.

Author(s)

Kaifeng Lu, kaifenglu@gmail.com

References

Patricia M. Grambsch and Terry M. Therneau. Proportional hazards tests and diagnostics based on weighted residuals. Biometrika 1994; 81:515-26.

Examples


fit <- phregr(data = liver, time = "Time", event = "Status", 
              covariates = c("log(Bilirubin)", "log(Protime)", 
                             "log(Albumin)", "Age", "Edema"),
              ties = "breslow")
              
zph <- zph_phregr(fit, transform = "log")
  
zph$table


trtswitch documentation built on Jan. 10, 2026, 5:08 p.m.