Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The concept you are looking for is known as <a href="http://en.wikipedia.org/wiki/Canonical_correlation" rel="noreferrer">canonical correlation</a>. It is a well developed bit of theory in the field of multivariate analysis. Essentially, the idea is to find a linear combination of the columns in your first matrix and a linear combination of the columns in your second matrix, such that the correlation between the two linear combinations is maximized. </p> <p>This can be done manually using eigenvectors and eigenvalues, but if you have the statistics toolbox, then Matlab has already got it packaged and ready to go for you. The function is called <code>canoncorr</code>, and the documentation is <a href="http://www.mathworks.com.au/help/stats/canoncorr.html" rel="noreferrer">here</a></p> <p>A brief example of the usage of this function follows:</p> <pre><code>%# Set up some example data CovMat = randi(5, 4, 4) + 20 * eye(4); %# Build a random covariance matrix CovMat = (1/2) * (CovMat + CovMat'); %# Ensure random covriance matrix is symmetrix X = mvnrnd(zeros(500, 4), CovMat); %# Simulate data using multivariate Normal %# Partition the data into two matrices X1 = X(:, 1:2); X2 = X(:, 3:4); %# Find the canonical correlations of the two matrices [A, B, r] = canoncorr(X1, X2); </code></pre> <p>The first canonical correlation is the first element of <code>r</code>, and the second canonical correlation is the second element of <code>r</code>.</p> <p>The <code>canoncorr</code> function also has a lot of other outputs. I'm not sure I'm clever enough to provide a satisfactory yet concise explanation of them here so instead I'm going to be lame and recommend you read up on it in a multivariate analysis textbook - most multivariate analysis textbooks will have a full chapter dedicated to canonical correlations.</p> <p>Finally, if you don't have the statistics toolbox, then a quick google revealed the following <a href="http://www.mathworks.com.au/matlabcentral/fileexchange/5230-acape/content/acape.m" rel="noreferrer">FEX submission</a> that claims to provide canonical correlation analysis - note, I haven't tested it myself.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload