Learn R Programming

eha (version 2.11.5)

plot.hazdata: Plots of hazdata objects.

Description

Baseline hazards estimates.

Usage

# S3 method for hazdata
plot(
  x,
  strata = NULL,
  fn = c("cum", "surv", "log", "loglog"),
  fig = TRUE,
  xlim = NULL,
  ylim = NULL,
  main = NULL,
  xlab = "",
  ylab = "",
  col = "black",
  lty = 1,
  printLegend = TRUE,
  ...
)

Value

A list where the elements are two-column matrices, one for each stratum in the model. The first column contains risktimes, and the second the y coordinates for the requested curve(s).

Arguments

x

A hazdata object, typically the 'hazards' element in the output from link{coxreg} with method = "ml" or method = "mppl" or coxph = FALSE.

strata

Stratum names if there are strata present.

fn

Which type of plot? Allowed values are "cum" (or "cumhaz"), "surv" (or "sur"), "log", or "loglog". The last two plots the cumulative hazards on a log (y) scale or a log-log (xy) scale, respectively.

fig

Should a plot actually be produced? Default is TRUE.

xlim

Horizontal plot limits. If NULL, calculated by the function.

ylim

Vertical plot limits. If NULL, set to c(0, 1) for a plot of the survival function.

main

A heading for the plot.

xlab

Label on the x axis.

ylab

Label on the y-axis.

col

Color of the lines. May be a vector of length equal to No. of strata.

lty

Line type(s). May be a vector of length equal to No. of strata.

printLegend

Logical or character; should a legend be produced? Defaults to TRUE. If character, it should be one of bottomleft, bottomright, etc, see legend.

...

Anything that plot.default likes...

Author

Göran Broström

Details

It is also possible to have as first argument an object of type "coxreg", given that it contains a component of type "hazdata".

Examples

Run this code

time0 <- numeric(50)
group <- c(rep(0, 25), rep(1, 25))
x <- runif(50, -0.5, 0.5)
time1 <- rexp( 50, exp(group) )
event <- rep(1, 50)
fit <- coxreg(Surv(time0, time1, event) ~ x + strata(group), method = "ml")
plot(fit$hazards, col = 1:2, fn = "surv", xlab = "Duration")
## Same result as:
## plot(fit, col = 1:2, fn = "sur", xlab = "Duration")

Run the code above in your browser using DataLab