Testing for statistical independence of two vectors

16 Ansichten (letzte 30 Tage)
Khaled Ghannam
Khaled Ghannam am 21 Feb. 2014
Kommentiert: John D'Errico am 24 Okt. 2018
Hi,
I'm a new Matlab user and was trying to test if two vectors (time series of temperature) are statistically independent. I know that their joint pdf has to be the product of the individual pdfs, but how to do that? Is there another way where one can say, to a certain confidence level (say 95%), that two time series are statistically independent.
Many thanks

Antworten (4)

Roger Stafford
Roger Stafford am 22 Feb. 2014
Bearbeitet: Roger Stafford am 22 Feb. 2014
It is a frequent mistake to assume that uncorrelated random variables must be independent. Actually that is true only if the random variables are known to be of a multivariate normal distribution. Otherwise, testing that they are independent is much more difficult. Basically it involves breaking the intersections of their two ranges into a meshwork of little boxes. If the probabilities of samples that fall in each box can be approximated by the product of the marginal sample probabilities of each random variable for the two corresponding box ranges, then they are (approximately) independent. The finer the meshwork, and the larger the sample count, the more reliable the independence finding is.
Often independence is established more on a theoretical basis than by such testing. For example, when we see two coins flipped that have no obvious connection we feel that their toss results must be independent.
In the case of your two vectors it will be necessary to have very long vectors so as to have a reasonable chance to fill each "box" with sufficiently many samples to make your judgement of independence or non-independence reliable. There is no shortcut to doing this.
  1 Kommentar
Khaled Ghannam
Khaled Ghannam am 22 Feb. 2014
Thanks Roger. I agree with you! One more bit, have anyone ever encountered some analysis of independence vs. correlation times? Is there some approximation or measure ( I assume it depends on the process itself) that says one can safely assume independence or weak independence after 2 or 3 integral scales (by computing correlation functions)?

Melden Sie sich an, um zu kommentieren.


Paul
Paul am 22 Feb. 2014
Correlation is one method to check dependence:
x=1:100;
y=1:100;
correl = corr(x(:),y(:))
x=rand(1,100);
y=rand(1,100);
correl_rand = corr(x(:),y(:))
  2 Kommentare
Khaled Ghannam
Khaled Ghannam am 22 Feb. 2014
Thanks Paul! I did the correlation. But if two vectors are uncorrelated then they are not necessarily independent, i.e two vectors can still be statistically dependent yet uncorrelated
Paul
Paul am 22 Feb. 2014
Ah ok, I'm not that much into statistics so cant help you much I suppose.

Melden Sie sich an, um zu kommentieren.


Star Strider
Star Strider am 22 Feb. 2014
Bearbeitet: Star Strider am 22 Feb. 2014
I suggest corrcoef. It gives the correlation coefficients, and if you ask it to, will return statistics on the correlations, including probabilities and 95% confidence intervals.
EDIT -- It took some searching, but Statistical Tests of Indepepdence may be what you’re looking for. It describes itself:
This package contains Matlab implementations of three statistical hypothesis tests for independence: a kernel test, as described in GreEtAl08a; and tests based on the L1 and log-likelihood, as described in GreEtAl08b,GreEtAl10.
  1 Kommentar
saba g
saba g am 24 Okt. 2018
Hi Star,
I think this package is the only in measuring the statistical test of independence. Actually, I have a problem in interpreting the results. I expected that my datasets are independent. I used the 'hiscTestGamma' function and the result shows me that the Threshold is 0.3 and the testStat is 70. I really get surprised I am not sure if these values show me that my datasets are not independence? I really appreciate your any kind of advice.

Melden Sie sich an, um zu kommentieren.


Soumojit Bose
Soumojit Bose am 14 Nov. 2017
If the joint PDF of the two variables is Gaussian, then in that case, 'uncorrelated' implies 'statistical independence'. This can be proved.
  1 Kommentar
John D'Errico
John D'Errico am 24 Okt. 2018
I think you are making a mistake here. It is entirely possible for two random variables to have a zero sample correlation, yet not be uncorrelated. Or they can have a non-zero correlation, yet be fully independent. A sample statistic does not prove correlation, it only provides evidence thereof.

Melden Sie sich an, um zu kommentieren.

Community Treasure Hunt

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

Start Hunting!

Translated by