pdf("g01.pdf");options(width=64) #setwd("C:\\Users\\kolassa\\Class542") setwd("~/Taught1/960-542/Data")
# Block 1
#*********************************************************/
# The Stanford heart transplant data from                */
# http://lib.stat.cmu.edu/datasets/stanford              */
# represents a prototypical survival analysis data set.  */
# Participants are waiting for a heart transplant.  Some */
# of them get the transplant before death; others do not.*/
# time is time in days to death or end of followup.      */
# status is 1 if time is death, and 0 if end of followup.*/
# wait is waiting time for transplant.                   */
#*********************************************************/
stanford<-read.table("stanford",skip=25,nrows=103,fill=TRUE,
   col.names=c("id","start","age","status","time","prior",
      "transp" ,"wait" ,"alleles" ,"antigen" ,"score"))
#****************************************/
# Exhibit complexities of survival data.*/
#****************************************/
#Print everything except the first column, with id
print(stanford[,-1],row.names=FALSE)
plot(range(pretty(stanford$time)),c(0,.005),type="n",
   xlab="Time (days)",ylab="Density",
   main="Remaining lifetimes for Stanford heart patients")
for(j in 0:1) hist(stanford$time[stanford$transp==j],
   freq=FALSE,lty=j+1,add=TRUE)
legend(400,.003,lty=c(2,1),
   legend=c("Received Transplant","Did not Receive Transplant"))
plot(range(pretty(log(stanford$time))),c(0,.5),type="n",
    xlab="Log Time (days)",ylab="Density",
    main="Remaining lifetimes for Stanford heart patients")
for(j in 0:1) hist(log(stanford$time[stanford$transp==j]),
   freq=FALSE,lty=j+1,add=TRUE)
legend(0,.4,lty=c(2,1),
   legend=c("Received Transplant","Did not Receive Transplant"))