pamr.test.errors.surv.compute      package:pamr      R Documentation

_A _f_u_n_c_t_i_o_n _g_i_v_i_n_g _a _t_a_b_l_e _o_f _t_r_u_e _v_e_r_s_u_s _p_r_e_d_i_c_t_e_d _v_a_l_u_e_s,
_f_r_o_m _a _n_e_a_r_e_s_t _s_h_r_u_n_k_e_n _c_e_n_t_r_o_i_d _f_i_t _f_r_o_m _s_u_r_v_i_v_a_l _d_a_t_a.

_D_e_s_c_r_i_p_t_i_o_n:

     A function giving a table of true versus predicted values, from a
     nearest shrunken centroid fit from survival data.

_U_s_a_g_e:

     pamr.test.errors.surv.compute(proby, yhat)

_A_r_g_u_m_e_n_t_s:

   proby: Survival class probabilities, from pamr.surv.to.class2

    yhat: Estimated class labels, from pamr.predict

_D_e_t_a_i_l_s:

     'pamr.test.errors.surv.compute' computes the erros between the
     true 'soft" class labels proby and the estimated ones "yhat"

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

     # 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

     # make class predictions for test data
     yhat <- pamr.predict(a3,dd$x, threshold=1.0)

     # compute test errors

     pamr.test.errors.surv.compute(proby, yhat)

