Hi guys,
I have lots of submatrices where I need to compute proportionality between each other.
The code that Kevin Blighe gave it to me allows me to compute the proportionality only on one submatrix itself. I need to use this function to get what I want function(x) 1 - ((var(data[i,] - x)) / (var(data[i,]) + var(x)))
res <- foreach(i = seq_len(nrow(data)), #the matrix here is data
.combine = rbind,
.multicombine = TRUE,
.inorder = FALSE,
.packages = c('data.table', 'doParallel')) %dopar% {
apply(data, 2, function(x) 1 - ((var(data[i,] - x)) / (var(data[i,]) + var(x))))
}
I want to get the proportionnality between each submatrix. We suppose I have two matrices a and b which have the same dimensions.
I found this function which allows to compute the correlation between these two submatrices. What I would like to do is to implement my function into this code in order to get ALL the pairwise proportionality between all my submatrices a, b, c, d......
cor_blocks<- function(a,b) {
M <- rbind(a, b);
M <- M - rowMeans(M);
M <- M / sqrt(rowSums(M^2));
CR <- tcrossprod(M)
edge <- dim(a)[1]
CR <- t(cr[1:edge, -c(1:edge)])
return(CR)
}
Bests, Vincent