library("survival")
library("coin")
library(survminer)
## Loading required package: ggplot2
## Loading required package: ggpubr
## Loading required package: magrittr
## Warning: Installed Rcpp (0.12.11) different from Rcpp used to build dplyr (0.12.12).
## Please reinstall dplyr to avoid random crashes or undefined behavior.
library(ggplot2)
library(ggfortify)
data(glioma)
so1<-Surv(time,event) ~ sex
survo<-Surv(time=glioma$time, event=glioma$event)
survf<- survfit(formula=survo~glioma$sex,data=glioma)
summary(survf)
## Call: survfit(formula = survo ~ glioma$sex, data = glioma)
##
## glioma$sex=Female
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 5 16 1 0.938 0.0605 0.826 1.000
## 8 15 3 0.750 0.1083 0.565 0.995
## 9 12 1 0.688 0.1159 0.494 0.957
## 14 11 2 0.562 0.1240 0.365 0.867
## 25 9 1 0.500 0.1250 0.306 0.816
## 53 3 1 0.333 0.1596 0.130 0.852
##
## glioma$sex=Male
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 6 21 1 0.952 0.0465 0.866 1.000
## 8 20 1 0.905 0.0641 0.788 1.000
## 11 19 1 0.857 0.0764 0.720 1.000
## 12 18 1 0.810 0.0857 0.658 0.996
## 13 17 1 0.762 0.0929 0.600 0.968
## 14 16 1 0.714 0.0986 0.545 0.936
## 15 15 1 0.667 0.1029 0.493 0.902
## 19 14 1 0.619 0.1060 0.443 0.866
## 20 13 1 0.571 0.1080 0.395 0.828
## 25 12 1 0.524 0.1090 0.348 0.788
## 31 11 1 0.476 0.1090 0.304 0.746
## 32 10 1 0.429 0.1080 0.262 0.702
## 34 9 1 0.381 0.1060 0.221 0.657
## 36 8 1 0.333 0.1029 0.182 0.610
plot(survf,lty=1:2, main="Glioma sex",log=TRUE, ylab="Probability",xlab="Survival Time")
autoplot(survf)
####Survival analysis for giloma on histology
so2<-Surv(time,event) ~ histology
survo1<-Surv(time=glioma$time, event=glioma$event)
survf1<- survfit(formula=survo1~glioma$histology,data=glioma)
summary(survf1)
## Call: survfit(formula = survo1 ~ glioma$histology, data = glioma)
##
## glioma$histology=GBM
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 5 20 1 0.95 0.0487 0.8591 1.000
## 6 19 1 0.90 0.0671 0.7777 1.000
## 8 18 4 0.70 0.1025 0.5254 0.933
## 11 14 1 0.65 0.1067 0.4712 0.897
## 12 13 1 0.60 0.1095 0.4195 0.858
## 13 12 1 0.55 0.1112 0.3700 0.818
## 14 11 3 0.40 0.1095 0.2339 0.684
## 15 8 1 0.35 0.1067 0.1926 0.636
## 20 7 1 0.30 0.1025 0.1536 0.586
## 25 6 1 0.25 0.0968 0.1170 0.534
## 31 5 1 0.20 0.0894 0.0832 0.481
## 36 4 1 0.15 0.0798 0.0528 0.426
##
## glioma$histology=Grade3
## time n.risk n.event survival std.err lower 95% CI upper 95% CI
## 9 17 1 0.941 0.0571 0.836 1.000
## 19 16 1 0.882 0.0781 0.742 1.000
## 25 15 1 0.824 0.0925 0.661 1.000
## 32 13 1 0.760 0.1048 0.580 0.996
## 34 12 1 0.697 0.1136 0.506 0.959
## 53 7 1 0.597 0.1341 0.385 0.927
plot(survf1,lty=1:2, main="Glioma Histology",log=TRUE, ylab="Probability",xlab="Survival Time")
autoplot(survf1)
library(TH.data)
## Loading required package: MASS
##
## Attaching package: 'TH.data'
## The following object is masked from 'package:MASS':
##
## geyser
data(GBSG2)
summary(GBSG2)
## horTh age menostat tsize tgrade
## no :440 Min. :21.00 Pre :290 Min. : 3.00 I : 81
## yes:246 1st Qu.:46.00 Post:396 1st Qu.: 20.00 II :444
## Median :53.00 Median : 25.00 III:161
## Mean :53.05 Mean : 29.33
## 3rd Qu.:61.00 3rd Qu.: 35.00
## Max. :80.00 Max. :120.00
## pnodes progrec estrec time
## Min. : 1.00 Min. : 0.0 Min. : 0.00 Min. : 8.0
## 1st Qu.: 1.00 1st Qu.: 7.0 1st Qu.: 8.00 1st Qu.: 567.8
## Median : 3.00 Median : 32.5 Median : 36.00 Median :1084.0
## Mean : 5.01 Mean : 110.0 Mean : 96.25 Mean :1124.5
## 3rd Qu.: 7.00 3rd Qu.: 131.8 3rd Qu.: 114.00 3rd Qu.:1684.8
## Max. :51.00 Max. :2380.0 Max. :1144.00 Max. :2659.0
## cens
## Min. :0.0000
## 1st Qu.:0.0000
## Median :0.0000
## Mean :0.4359
## 3rd Qu.:1.0000
## Max. :1.0000
GBSG2$event<- 1-GBSG2$cens
survo2<-Surv(time=GBSG2$time, event=GBSG2$event)
survf2<- survfit(formula=survo2~GBSG2$horTh, data=GBSG2)
s<-summary(survf2)
plot(survf2, lty=1:2, main="GBSG2 horTh survival analysis", log=TRUE,
ylab="Probability", xlab="Survival TIME")
autoplot(survf2)