Learn R Programming

biostat3 (version 0.1.4)

coxphHaz: Smoothed hazard estimates for coxph

Description

Smoothed hazard estimates for coxph

Usage

coxphHaz(object, newdata, n.grid = 300, kernel = "epanechnikov", from,
to, ...)
# S3 method for coxphHaz
print(x, digits=NULL, ...)
# S3 method for coxphHaz
plot(x, xlab="Time", ylab="Hazard", type="l", ...)
# S3 method for coxphHazList
plot(x, xlab="Time", ylab="Hazard", type="l",
                  col=1:length(x), lty=1, legend.args=list(), ...)
# S3 method for coxphHazList
lines(x, ...)

Arguments

object

coxph object

newdata

data-frame with covariates for prediction

n.grid

the number of grid values for which the hazard is calculated

kernel

the kernel used for smoothing

from

argument for density. Defaults to the minimum time.

to

argument for density. Defaults to the maximum time.

x

object

digits

argument passed to print.density

col

graphics argument

lty

graphics argument

xlab

graphics argument

ylab

graphics argument

type

graphics argument

legend.args

a list of options that are passed to the legend call. Defaults are list(x="topright",legend=strata(attr(x,"newdata")),col=col,lty=lty).

other arguments. For coxphHaz, these arguments are passed to density. For the plot and lines methods, these are passed to the relevant plot, matplot and matlines functions.

Value

The coxphHaz function returns either a class of type c("coxphHaz","density") when newdata has one row or, for multiple rows in newdata, a class of type "coxphHazList", which is a list of type c("coxphHaz","density").

Details

Smooth hazard estimates from a Cox model using kernel smoothing of the Nelson-Aalen estimator.

See Also

coxph, survfit, density

Examples

Run this code
# NOT RUN {
fit <- coxph(Surv(surv_mm/12,status=="Dead: cancer")~agegrp, data=colon)
newdata <- data.frame(agegrp=levels(colon$agegrp))
haz <- suppressWarnings(coxphHaz(fit,newdata))
plot(haz, xlab="Time since diagnosis (years)")
legend("topright", legend=newdata$agegrp, lty=1:4, col=1:4, bty="n")
# }

Run the code above in your browser using DataLab