pamr.plotsurvival            package:pamr            R Documentation

_A _f_u_n_c_t_i_o_n _t_o _p_l_o_t_s _K_a_p_l_a_n-_M_e_i_e_r _c_u_r_v_e_s _s_t_r_a_t_i_f_i_e_d _b_y _a _g_r_o_u_p _v_a_r_i_a_b_l_e

_D_e_s_c_r_i_p_t_i_o_n:

     A function to plots Kaplan-Meier curves stratified by a group
     variable

_U_s_a_g_e:

     pamr.plotsurvival(group, survival.time, censoring.status)

_A_r_g_u_m_e_n_t_s:

   group: A grouping factor

survival.time: Vector of survival times

censoring.status: Vector of censoring status values: 1=died, 0=censored 

_D_e_t_a_i_l_s:

_V_a_l_u_e:

_A_u_t_h_o_r(_s):

     Trevor Hastie,Robert Tibshirani, Balasubramanian Narasimhan, and
     Gilbert Chu

_R_e_f_e_r_e_n_c_e_s:

_E_x_a_m_p_l_e_s:

     gendata<-function(n=100, p=2000){
       tim <- 3*abs(rnorm(n))
       u<-runif(n,min(tim),max(tim))
       y<-pmin(tim,u)
        ic<-1*(tim<u)
     m <- median(tim)
     x<-matrix(rnorm(p*n),ncol=n)
       x[1:100, tim>m] <-  x[1:100, tim>m]+3
       return(list(x=x,y=y,ic=ic))
     }

     # generate training data; 2000 genes, 100 samples

     junk<-gendata(n=100)
     y<-junk$y
     ic<-junk$ic
     x<-junk$x
     d <- list(x=x,survival.time=y, censoring.status=ic,
     geneid=as.character(1:nrow(x)), genenames=paste("g",as.character(1:nrow(x)),sep=
     ""),)

     # train model
     a3<- pamr.train(d, ngroup.survival=2)

     #make class predictions

     yhat <- pamr.predict(a3,d$x, threshold=1.0)

     pamr.plotsurvival(yhat, d$survival.time, d$censoring.status)

