Off topic:Compute the proportionality between manu submatrices
0
0
Entering edit mode
5.1 years ago
pablo ▴ 300

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

correlation proportionality R matrix • 501 views
ADD COMMENT
This thread is not open. No new answers may be added
Traffic: 2478 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6