필터 지우기
필터 지우기

calculate the correlation of a number of time series

조회 수: 2 (최근 30일)
Richard
Richard 2012년 7월 19일
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?

채택된 답변

Andrei Bobrov
Andrei Bobrov 2012년 7월 20일
편집: Andrei Bobrov 2012년 7월 20일
R = arrayfun(@(x)nonzeros(tril(corrcoef(data(:,x),mean(data(:,setdiff(1:size(data,2),x))')'),-1)),1:size(data,2));
or
for k = size(data,2):-1:1
R(k) = nonzeros(tril(corrcoef(data(:,k),mean(data(:,[1:k-1,k+1:end]),2)),-1));
end
or
for k = size(data,2):-1:1
p = corrcoef(data(:,k),mean(data(:,[1:k-1,k+1:end]),2));
R(k) = p(2);
end

추가 답변 (2개)

bym
bym 2012년 7월 19일
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

Teja Muppirala
Teja Muppirala 2012년 7월 20일
diag( corr( bsxfun(@minus, sum(data,2), data), data) )

카테고리

Help CenterFile Exchange에서 Tables에 대해 자세히 알아보기

태그

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by