################################################################################# # Bayesian model selection and statistical modeling # Chapman & Hall/CRC Taylor and Francis Group # # Chapter5: Section5.5.4 # # Survival analysis # # Author : Tomohiro Ando # ################################################################################ library(survival) data(ovarian) D <- as.matrix(ovarian) E <- D[,-(1:2)]; E[,2:4] <- E[,2:4] - 1 y <- as.vector(D[,1])/100 z <- as.vector(D[,2]) n <- length(y) # Fit exponential model fit1 <- survreg(Surv(y,z) ~E[,1]+E[,2]+E[,3]+E[,4], dist="exponential") fit1 <- step(fit1) BIC1 <- -2*( (fit1$loglik)[2] )+log(n)*length(fit1$coef) # Fit weibull model fit2 <- survreg(Surv(y,z) ~E[,1]+E[,2]+E[,3]+E[,4], dist="weibull") fit2 <- step(fit2) BIC2 <- -2*( (fit2$loglik)[2] )+log(n)*length(fit2$coef) # Fit loglogistic model fit3 <- survreg(Surv(y,z) ~E[,1]+E[,2]+E[,3]+E[,4], dist="loglogistic") fit3 <- step(fit3) BIC3 <- -2*( (fit3$loglik)[2] )+log(n)*length(fit3$coef) # Fit extreme model fit4 <- survreg(Surv(y,z) ~E[,1]+E[,2]+E[,3]+E[,4], dist="extreme") fit4 <- step(fit4) BIC4 <- -2*( (fit4$loglik)[2] )+log(n)*length(fit4$coef) summary(fit1) summary(fit2) summary(fit3) summary(fit4) print(BIC1) print(BIC2) print(BIC3) print(BIC4)