pamr.surv.to.class2           package:pamr           R Documentation

_A _f_u_n_c_t_i_o_n _t_o  _a_s_s_i_g_n _o_b_s_e_r_v_a_t_i_o_n_s _t_o _c_a_t_e_g_o_r_i_e_s, _b_a_s_e_d _o_n _t_h_e_i_r
_s_u_r_v_i_v_a_l _t_i_m_e_s.

_D_e_s_c_r_i_p_t_i_o_n:

     A function to  assign observations to categories, based on their
     survival times.

_U_s_a_g_e:

     pamr.surv.to.class2(y, icens, cutoffs=NULL, n.class=NULL,  class.names=NULL, newy=y, newic=icens)

_A_r_g_u_m_e_n_t_s:

       y: vector of survival times

   icens: Vector of censorng status values: 1=died, 0=censored

 cutoffs: Survival time cutoffs for categories. Default NULL

 n.class: Number of classes to create: if cutoffs is NULL, n.class
          equal classes are created.

class.names: Character names for classes

    newy: New set of survival times, for which probabilities are
          computed (see below). Default is y

   newic: New set of censoring statuses, for which probabilities are
          computed (see below). Default is icens

_D_e_t_a_i_l_s:

     'pamr.pamr.surv.to.class2'  splits observations into categories
     based on their survival times and the Kaplan-Meier estimates. For
     example if n.class=2, it makes two categories, one below the
     median survival, the other above. For each observation (newy, ic),
     it then computes the probability of that observation falling in
     each category. For an uncensored observation that probability is
     just  1 or 0 depending on when the death occurred. For a censored
     observation, the probabilities are based on the Kaplan Meier and
     are typically between 0 and 1.

_V_a_l_u_e:

   class: 

    prob: The estimates class probabilities

 cutoffs: The cutoffs used

_A_u_t_h_o_r(_s):

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

_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)

     # generate test data
     junkk<- gendata(n=500)

     dd <- list(x=junkk$x, survival.time=junkk$y, censoring.status=junkk$ic)

     # compute soft labels
     proby <-  pamr.surv.to.class2(dd$survival.time, dd$censoring.status,
                  n.class=a3$ngroup.survival)$prob

