library(survival) ghn <- read.table("gehan.dat", header=T) #ghn <- read.table("/home/jane/public_html/gehan.dat", header=T) # *.dead gives the censoring information. '1' is observed, '0' censored attach(ghn) time <- c(X6.MP.time,control.time) group <- c(rep(1,21),rep(0,21)) dead <- c(X6.MP.dead, control.dead) ghn.surv <- survfit(Surv(time, dead) ~ group, conf.type="log-log") plot(ghn.surv, xlab="Weeks", ylab="Estimated survival function", conf=T, lty=c(1,2)) # include confidence intervals, use different line types 'lty' for groups title(main="Remission of leukaemia patients") legend(25,0.95, c("Controll","6MP"),lty=c(1,2)) t <- seq(0.1,max(time),0.1) # set up time for lines. lines(t, exp(-21*t/182)) lines(t, exp(-9*t/359), lty=2) ctl.exp <- survreg(Surv(control.time,control.dead) ~1, dist="exp") mp.exp <- survreg(Surv(time[group==1], dead[group==1]) ~ 1, dist="exp") ghn.exp <- survreg(Surv(time, dead) ~ group, dist="exp") names(ghn.exp) ghn.exp$coef ; rho0 <- ghn.exp$coef[1] ; (rho1 <- rho0 + ghn.exp$coef[2]) lam0 <- exp(-rho0); lam1 <- exp(-rho1) lines(t, exp(-lam0*t) ) ; lines(t, exp(-lam1*t), lty=2 ) ctl.wei <- survreg(Surv(control.time,control.dead) ~1, dist="weib") mp.wei <- survreg(Surv(time[group==1], dead[group==1]) ~ 1, dist="weib") ghn.wei <- survreg(Surv(time, dead) ~ group, dist="wei") summary(ghn.wei) ; names(ghn.wei) ghn.wei$coef ; alpha <- ghn.wei$scale rho0 <- ghn.wei$coef[1] ; (rho1 <- rho0 + ghn.wei$coef[2]) Wlam0 <- exp(-ghn.wei$coef[1]); Wlam1 <- exp(-(ghn.wei$coef[1]+ghn.wei$coef[2])) lines(t, exp( -(lam0*t)^alpha ) ); lines(t, exp( -(lam1*t)^alpha ) , lty=2 ) lines(t, exp( -(lam0*t)^alpha ) ,lty=3) lines(t, exp( -(lam1*t)^alpha ) , lty=4 ) ctl.ll <- survreg(Surv(control.time,control.dead) ~1, dist="logl") mp.ll <- survreg(Surv(time[group==1], dead[group==1]) ~ 1, dist="logl") ghn.ll <- survreg(Surv(time, dead) ~ group, dist="logl")