views:

46

answers:

1

I have a 2 vectors of numbers of either 1 or -1. What are the standard tools on Matlab that would help me calculate a correlation number between the two vectors? Thanks in advance!

+1  A: 

The CORRCOEF function is what you're looking for:

R = corrcoef(vector1(:),vector2(:));  %# Returns a 2-by-2 matrix of
                                      %#   correlation coefficients

If you have the Statistics Toolbox, you may also want to check out the function CORR:

RHO = corr(vector1(:),vector2(:));  %# Returns the linear correlation coefficient
                                    %#   (default is a Pearson correlation)
gnovice
And these work for non-continuous data as well? I'm not an expert on correlation, but the fact that his data is binary raises a flag in my head.
Kena
Here's my answer: http://en.wikipedia.org/wiki/Phi_coefficient"In statistics, the phi coefficient φ or rφ is a measure of association for two binary variables. This measure is similar to the Pearson correlation coefficient in its interpretation. In fact, a Pearson correlation coefficient estimated for two binary variables will return the phi coefficient.[1] "
Kena

related questions