# [R] Problems in Constructing Two way Matrix

Berend Hasselman bhh at xs4all.nl
Wed Jun 19 10:32:14 CEST 2013

```I'm cc'ing this to the R-help list.

You will get more response that way.

Berend

On 19-06-2013, at 10:29, Fazli Raziq <raziq_fazli at yahoo.com> wrote:

> Dear Mr. Berend,
>
> I want to construct "Two way Matrix". The Algorithm is like:
>
> 1)  Data of time with censoring or events
> 2)  Predictor variables (genes)
> 3)  Resample data in step 1 and 2 by WR
> 4)  Apply Coxph Model to resample data. Apply Surv function to each Predictor variable, individually.
> 5)  Give value 1 if it's P-value is less than 0.05, otherwise 0. Save it in the first Column (Column of 0's and 1's) of the Matrix.
> 6)  Iterate the process 1 to 5, 10 times. And make 10 Columns of 0's and 1's.
>
> I have done the programming for it, but gives problem in Matrix.
> Thanks for replying to my mail. Hope for the best.
>
> Best Regards
> Fazli Raziq
>
> From: Berend Hasselman <bhh at xs4all.nl>
> To: Fazli Raziq <raziq_fazli at yahoo.com>
> Cc: "r-help at r-project.org" <r-help at r-project.org>
> Sent: Wednesday, 19 June 2013, 9:43
> Subject: Re: [R] Problems in Constructing Two way Matrix
>
>
> On 19-06-2013, at 09:30, Fazli Raziq <raziq_fazli at yahoo.com> wrote:
>
> > Hello,
> >
> > Where is the problem in this programming. I want two way matrix, but it gives problem.
>
> What is the problem?
> What are you expecting and what are you getting?
>
> > The program is given below:
> >
> >
> > Regards
> > Fazli Raziq
> >
> >
> > rep = 2
> > genes = 5
> > pred = c()
> > iter  = array (dim = c(rep, pred))
> > pred = array(dim = c(1, genes))
> > m = c()
> > l = 1
> > w = 1
> > for(m in 1:rep) {
> > t = time
> > c = cens
> > tab = cbind(t, c)
> >
> > # Resampling Time and Censoring
> > cc = sample(c, replace = TRUE)
> > tt = sample(t, replace = TRUE)
> > xx = Surv(tt, cc)
> >
> > P = predic[,1:5]
> > n = 310
> > ma = matrix(P, n)
> > boot <- sample(seq(n), replace=TRUE)
> > genes5 = ma[boot, ]
> >
> >
> > for(p in 1: genes){
> > i = c()
> >
> > for(i in w:l) {
> > z = genes5[,w: l]
> > y = coxph(xx ~ z)
> >
> > }
> > Pval = summary(y) \$ coeff[, 5]
> >
> > if( any(Pval <= 0.01) ) sign <- 1 else sign <- 0
> > pred[1, p] = sign[1]
> > }
> >
> > iter [m, 1:5] = pred[1: 5]
> >
> > }
>
> Running this code gives an error message:
>
>
>
> And what is the purpose of t = time? time is a stats function.
> >     [[alternative HTML version deleted]]
> >
>
> You are asked to NOT post in html.
>
> Berend
>
> > ______________________________________________
> > R-help at r-project.org mailing list
> > https://stat.ethz.ch/mailman/listinfo/r-help