Be the first to rate this file! 73 downloads (last 30 days) File Size: 28.43 KB File ID: #20846

Weighted Correlation Matrix

by Francesco Pozzi

 

24 Jul 2008 (Updated 25 Jul 2008)

No BSD License  

Compute coefficients of the Weighted Correlation Matrix, as an alternative to CORRCOEFF

Download Now | Watch this File

File Information
Description

WEIGHTEDCORRS returns a symmetric matrix R of weighted correlation coefficients calculated from an input T-by-N matrix Y whose rows are observations and whose columns are variables and an input T-by-1 vector w of weights for the observations. This function may be a valid alternative to CORRCOEF if observations are not all equally relevant and need to be weighted according to some theoretical hypothesis or knowledge.  
 
R = WEIGHTEDCORRS(Y, w) returns a positive semidefinite matrix R, i.e. all its eigenvalues are non-negative (see Example 1 in help section).  
 
WEIGHTEDCORRS is such that WEIGHTEDCORRS(Y, w) == WEIGHTEDCORRS(a * Y + b, w) where a and b are two real numbers (see Example 1 in help section).  
 
Furthermore, the result provided by the function doesn't change if the unit system of each column of Y is changed through an arbitrary affine transformation y = a * x + b, where a and b are two real numbers, with a > 0 (see Example 2 in help section).  
 
If w = ones(size(Y, 1), 1), no difference exists between WEIGHTEDCORRS(Y, w) and CORRCOEF(Y) (see Example 4 in help section).  
 
**************************************  
Example: how to use the function  
 
T = 1000; % number of observations  
w = 1:T; % choose weights  
 
Y(:, 1) = (1:T) - T / 2 - 0.5;  
Y(:, 2) = rand * Y(:, 1) .^ 2 + rand; % Parabolic relation (symmetric)  
 
r1 = corrcoef(Y) % Traditional Correlation Matrix  
r2 = weightedcorrs(Y, w) % Weighted Correlation Matrix  
 
**************************************  
 
Lots of examples in the help section

MATLAB release MATLAB 7 (R14)
Tags for This File  
Everyone's Tags
Tags I've Applied
Add New Tags Please login to tag files.
Please login to add a comment or rating.
Tag Activity for this File
Tag Applied By Date/Time
statistics Francesco Pozzi 22 Oct 2008 10:11:42
probability Francesco Pozzi 22 Oct 2008 10:11:42
weighted correlation Francesco Pozzi 22 Oct 2008 10:11:42
correlation Francesco Pozzi 22 Oct 2008 10:11:42
correlation Jay 14 Feb 2009 13:13:17

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com