gg_coxsnell: Overall model fit diagnostic via Cox-Snell residuals.

Description Usage Arguments Value Examples

View source: R/coxph_plots.R

Description

gg_coxsnell extracts Cox-Snell residuals from an coxph object (which for a correct model should be a censored sample from Exp(1)) and the cumulative hazard rate of the residuals vs. the residuals.

Usage

1
gg_coxsnell(fit, type = c("cumu_hazard", "cdf"))

Arguments

fit

the result of fitting a Cox regression model, using the coxph or coxme functions.

type

character. Optional argument. If "cumu_hazard" plots cumulative hazard (Nelson-Aalen estimate) vs. Cox-Snell residuals. If "cdf" plot empirical cumulative distribution Function (Breslow estimate) vs. Cox-Snell residuals.

Value

A ggplot object.

Examples

1
2
3
4
5
6
7
8
library(survival)
library(ggplot2)
data("tongue", package="KMsurv")
cox.tongue <- coxph(Surv(time, delta)~as.factor(type), data=tongue)
gg_coxsnell(cox.tongue) +
 geom_abline(intercept=0, slope=1, col=2)
gg_coxsnell(cox.tongue, type="cdf") +
 geom_line(aes(y=F), col=2)

adibender/ldatools documentation built on March 7, 2020, 5:30 a.m.