Description Survival in patients with advanced lung cancer from the North Central Cancer Treatment Group. Performance scores rate how well the patient can perform usual daily activities. Usage: lung cancer Format: inst: Institution code time: Survival time in days status: censoring status 1=censored, 2=dead age: Age in years sex: Male=1 Female=2 ph.ecog: ECOG performance score (0=good 5=dead) ph.karno: Karnofsky performance score (bad=0-good=100) rated by physician pat.karno: Karnofsky performance score as rated by patient meal.cal: Calories consumed at meals wt.loss: Weight loss in last six months
library(ggfortify)
## Loading required package: ggplot2
## Warning: namespace 'DBI' is not available and has been replaced
## by .GlobalEnv when processing object 'call.'
## Warning: namespace 'DBI' is not available and has been replaced
## by .GlobalEnv when processing object 'call.'
library(survival)
head(lung)
## inst time status age sex ph.ecog ph.karno pat.karno meal.cal wt.loss
## 1 3 306 2 74 1 1 90 100 1175 NA
## 2 3 455 2 68 1 0 90 90 1225 15
## 3 3 1010 1 56 1 0 90 90 NA 15
## 4 5 210 2 57 1 1 90 60 1150 11
## 5 1 883 2 60 1 0 100 90 NA 0
## 6 12 1022 1 74 1 1 50 80 513 0
fit <- survfit(Surv(time, status) ~ sex, data = lung)
autoplot(fit)
You can also embed plots, for example:
autoplot(fit, surv.linetype = 'dashed', conf.int = FALSE,
censor.shape = '*', censor.size = 5, facets = TRUE, ncol = 2)
autoplot(survfit(Surv(time, status) ~ 1, data = lung), surv.colour = 'orange', censor.colour = 'red')
autoplot(survfit(Surv(time, status) ~ sex, data = lung), fun = 'event')
d.coxph <- survfit(coxph(Surv(time, status) ~ sex, data = lung))
autoplot(d.coxph, surv.linetype = 'dashed', surv.colour = 'blue',
conf.int.fill = 'dodgerblue3', conf.int.alpha = 0.5, censor = FALSE)
Also, you can use autoplot for survival::aareg instance.
# Fit a model to the lung cancer data set
lfit <- aareg(Surv(time, status) ~ age + sex + ph.ecog, data=lung,
nmin=1)
lfit
## Call:
## aareg(formula = Surv(time, status) ~ age + sex + ph.ecog, data = lung,
## nmin = 1)
##
## n=227 (1 observation deleted due to missingness)
## 138 out of 138 unique event times used
##
## slope coef se(coef) z p
## Intercept 5.26e-03 5.99e-03 4.74e-03 1.26 0.207000
## age 4.26e-05 7.02e-05 7.23e-05 0.97 0.332000
## sex -3.29e-03 -4.02e-03 1.22e-03 -3.30 0.000976
## ph.ecog 3.14e-03 3.80e-03 1.03e-03 3.70 0.000214
##
## Chisq=26.73 on 3 df, p=6.7e-06; test weights=aalen
autoplot(aareg(Surv(time, status) ~ age + sex + ph.ecog, data = lung))