No BSD License  

Highlights from
Weighted Correlation Matrix

4.0

4.0 | 1 rating Rate this file 21 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)

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

| 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.
Comments and Ratings (1)
23 Mar 2011 Tan Dem

Great job, but it would be better if the function could create a time series of correlation matrices recursively.

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
correlation Francesco Pozzi 22 Oct 2008 10:11:42
weighted correlation Francesco Pozzi 22 Oct 2008 10:11:42
correlation Jay 14 Feb 2009 13:13:17
weighted correlation Shurick Burenin 20 Jul 2011 21:30:40
correlation Chun-hui 25 Jul 2011 04:33:44

Contact us at files@mathworks.com