Learn R Programming

rankhazard (version 0.8-1)

rankhazardplot: Create a rank-hazard plot

Description

rankhazardplot creates a rank-hazard plot of the covariates of a proportional hazards model.

Usage

rankhazardplot(...)
## S3 method for class 'coxph':
rankhazardplot(coxphobj,refvalues=NULL,x=NULL,legendtext=NULL,axistext=NULL,plottype="hazard",...)
## S3 method for class 'cph':
rankhazardplot(cphobj,refvalues=NULL,x=NULL,legendtext=NULL,axistext=NULL,plottype="hazard",...)
## S3 method for class 'default':
rankhazardplot(x,coefs=NULL,xp=NULL,refvalues=NULL,legendtext=NULL,axistext=NULL,plottype="hazard",col=NULL,pch=NULL,lwd=1,...)

Arguments

coxphobj
An object of class 'coxph' (survival).
cphobj
An object of class 'cph' (rms).
refvalues
A vector of reference values given in the same order as the covariates in the model. If NULL, the medians of each covariate are used.
x
A matrix or data frame of the covariate data. Needed if the coxphobj$x or cphobj$x does not exist.
legendtext
A vector of covariate names for the legend box. If NULL, the column names are from x, coxphobj$x or cphobj$x.
axistext
A vector of covariate names and units for the x-axis. If NULL, the column names are from x, coxphobj$x or cphobj$x.
plottype
Scaling for the y-axis. Either "hazard" for the relative hazard with log-scale or "loghazard" for the logarithm of the relative hazard with linear scale.
coefs
A vector of regression coefficients for the covariates. If NULL, xp is required.
xp
Predictions ("terms") for the covariates. If NULL, coefs is required and xp is calculated a product of coefs and x.
col
See documentation for par.
pch
See documentation for points.
lwd
See documentation for par.
...
Other arguments to passed to the plotting commands.

Details

The function receives a coxph (package survival) object or a cph (package rms) object as an argument and creates a rank-hazard plot of the covariates. The reference values for the relative hazards and legend texts can be provided as optional arguments. Plotting parameters such as, lwd, lty, col and pch are passed to the plotting commands.

References

J. Karvanen, F. E. Harrell Jr., Visualizing covariates in proportional hazards model. Statistics in Medicine, 28:1957--1966, 2009.

See Also

coxph and cph

Examples

Run this code
library(survival)
model <- coxph(Surv(time,status) ~ age + sex + ph.karno, data=cancer, x=TRUE)
rankhazardplot(model)

Run the code above in your browser using DataLab