Displaying 2 results from an estimated 2 matches for "m1_".
Did you mean:
m1
2008 Nov 26
2
Very slow: using double apply and cor.test to compute correlation p.values for 2 matrices
My two matrices are roughly the sizes of m1 and m2. I tried using two apply and cor.test to compute the correlation p.values. More than an hour, and the codes are still running. Please help to make it more efficient.
m1 <- matrix(rnorm(100000), ncol=100)
m2 <- matrix(rnorm(10000000), ncol=100)
cor.pvalues <- apply(m1, 1, function(x) { apply(m2, 1, function(y) { cor.test(x,y)$p.value
2009 Mar 09
5
Help
...9;m
> using your original matrices. My session info is at the end. I'm using a
> 2.4 GHz Core 2-Duo processor and 3 GB of RAM.
>
> # Data
> set.seed(123)
> m1 <- matrix(rnorm(100000), ncol=100)
> m2 <- matrix(rnorm(100000), ncol=100)
> colnames(m1)=paste('m1_',1:100,sep="")
> colnames(m2)=paste('m2_',1:100,sep="")
>
> # Combinations
> combs=expand.grid(colnames(m1),colnames(m2))
>
> # ---------------
> # Option 1
> #----------------
> system.time(apply(combs,1,function(x)
> cor.test(m1[,x[1...