variables in two matrix
1
0
Entering edit mode
@john-linux-user-4917
Last seen 9.0 years ago
United States

Hi,

What package would be best to systematically understand the correlation of variables in two matrix, such as v1, v2, ...vn in matrix 1, vb1, vb2,...vbn in matrix2?  I would like to know which variable in matrix 1  has the most correlation in a variable in matrix 2. CCA seemed perform the similar job, but the output plot was not what I expected. Any suggestions would be appreciated.

Best,

John

 

 

variable • 768 views
ADD COMMENT
0
Entering edit mode
Matthias Z. ▴ 20
@matthias-z-8768
Last seen 7.3 years ago
University Medical Center of Münster, G…

Presuming you have numerical variables only, you could try:

library(Hmisc)
#as example
matrixA <- as.matrix(mtcars[1:3])
matrixB <- as.matrix(mtcars[4:6])
rcorr(matrixA,matrixB)

This for example computes a matrix of Pearson's r or Spearman's rho rank correlation coefficients.

Since you mentioned plotting, you might want to try out correlation matrix plot from the psych package - this however demands to unite your data into one matrix first:

library(psych)
pairs.panels(matrixA)

Best

Matthias

ADD COMMENT

Login before adding your answer.

Traffic: 563 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