Correlation of two variables over time: can this happen?

조회 수: 6 (최근 30일)
alpedhuez
alpedhuez 2020년 12월 17일
편집: alpedhuez 2020년 12월 17일
I have a variable x1 and x2 between January 1 till December 31. When I calculate the correlation between Janaury and June it is positive. When I calculate the correlation between July to December it is positive. But the correlation between Janauary and December is negative. Can it happen?
  댓글 수: 1
Matt Gaidica
Matt Gaidica 2020년 12월 17일
Yes. However, you probably want to perform a statistical test to determine if the fluctuating correlation is significant.

댓글을 달려면 로그인하십시오.

채택된 답변

the cyclist
the cyclist 2020년 12월 17일
Yes. This is known as Simpson's Paradox. Here is an example:
rng default
x1 = [1 2 3 4 6 7 8 9]';
x2 = [1 2 3 4 -6 -5 -4 -3]' + 0.8*rand(8,1);
% Correlation of first half
corrcoef(x1(1:4),x2(1:4))
% Correlation of second half
corrcoef(x1(5:8),x2(5:8))
% Correlation of entire vector
corrcoef(x1,x2)
% Plot it
figure
scatter(x1,x2)
You can see that the first half and the second half are positively correlated with each other, but if you look at the trend over the entire vector, it is negative.
  댓글 수: 7
Ive J
Ive J 2020년 12월 17일
It was useful anyway!
alpedhuez
alpedhuez 2020년 12월 17일
편집: alpedhuez 2020년 12월 17일
Yes I now understand confounding factor t.
x1 and x2 has a postive correlation between date 1 and date 2.
x1 and x2 has a positive correltion between date 2 and date 3.
x1 and x2 has a negative correlation betwen date 1 and date 3.
Regression of x2 on x1 between date 1 and date 2 has positive statistically sig coef.
Regression of x2 on x1 between date 2 and date 3 has positive statistically sig coef.
Regression of x2 on x1 between date 1 and date 3 has negative statistically sig coef.
Regression of x2 on x1 and time between date 1 and date 2 has positive statistically sig coef for both x1 and time.
Regression of x2 on x1 and time between date 2 and date 3 has positive statistically sig coef for both x1 and time.
Regression of x2 on x1 and time between date 1 and date 3 has positive statistically sig coef for both x1 and time.
How can it happen?

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Matt Gaidica
Matt Gaidica 2020년 12월 17일
편집: Matt Gaidica 2020년 12월 17일
Sure, it can happen. What's your concern about it?
  댓글 수: 4
Image Analyst
Image Analyst 2020년 12월 17일
For a thorough explanation see the Wikipedia link in the Cyclist's answer below. (He beat me to it, posting this fun paradox.)
It would be interesting for us to know what real world measurements x1 and x2 are so we can see a real world situation that gives rise to this parabox. What do x1 and x2 represent?
alpedhuez
alpedhuez 2020년 12월 17일
편집: alpedhuez 2020년 12월 17일
I am happy to explain to get comments. But I am not sure whether I want to discuss the problem in a public bulletin board. So if there is a suggestion for a venue I will be happy to listen.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Conditional Mean Models에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by