calculate the correlation of a number of time series
Ältere Kommentare anzeigen
If I have a matrix:
data = rand(365,5);
What is the most appropriate way of calculating the correlation between each column and the mean of the remaining columns. For example, for the first column:
R = nonzeros(tril(corrcoef(data(:,1),mean(data(:,2:end)')'),-1));
How could I repeat this procedure so that I have 5 correlation values i.e. for each series?
Akzeptierte Antwort
Weitere Antworten (2)
bym
am 19 Jul. 2012
Don't know what you are trying to accomplish, but here is one way
clc; clear
data = rand(365,5);
for k = 1:5
r = corrcoef(data(:,1),mean(data(:,2:end),2));
R(k) = r(2);
data = circshift(data,-1);
end
R
1 Kommentar
Andrei Bobrov
am 20 Jul. 2012
data = circshift(data,[0 -1]);
Teja Muppirala
am 20 Jul. 2012
diag( corr( bsxfun(@minus, sum(data,2), data), data) )
1 Kommentar
Teja Muppirala
am 20 Jul. 2012
CORR is from the Statistics Toolbox
Kategorien
Mehr zu Correlation and Convolution finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!