P-value of cross-correlation

53 ビュー (過去 30 日間)
Sepp
Sepp 2018 年 8 月 23 日
編集済み: Alex Backer 2020 年 5 月 7 日
Hello everybody
I have two time series Xa and Ya from which I'm calculating the cross-correlation vm2 in Matlab in the following way:
% after aligning signals, take the part of signal Xa with equal lentht of Ya
if length(Xa) > length(Ya)
[R2, lags2] = xcorr(Xa(1:length(Ya)),Ya,'coeff');
else
[R2, lags2] = xcorr(Ya(1:length(Xa)),Xa,'coeff');
end
[vm2, im2] = max(R2); % max. correlation and index
Unfortunately, I'm not getting a p-value from the xcorr method. Could I somehow first remove the lag which I retrieve from xcorr and then using corrcoef to get the correlation with p-value? Or how can I else calculate the p-value of the correlation of these two signals?

回答 (2 件)

Jeff Miller
Jeff Miller 2018 年 8 月 24 日
If I understand, you are looking for the tail probability of vm2 within the Pearson's r distribution. That distribution doesn't seem to be supported by MATLAB, though they have many others used in hypothesis testing (t, F, chi-squared). The r distribution is included in Cupid , so if you download that you could potentially use
myR = r(min(length(Xa),length(Ya));
p = 1 - myR.CDF(vm2); % one-tailed, for positive r
% or, p = 2*(1 - myR.CDF(vm2)); % two-tailed, for positive r
  1 件のコメント
Alex Backer
Alex Backer 2020 年 5 月 5 日
Thanks!

サインインしてコメントする。


Alex Backer
Alex Backer 2020 年 5 月 7 日
編集済み: Alex Backer 2020 年 5 月 7 日
I found Jeff's code above was giving me p-values that seemed too low, even for random series, so I wrote some code to estimate the p-value empirically:
Alex Backer (2020). xcorrpvalue (https://www.mathworks.com/matlabcentral/fileexchange/75403-xcorrpvalue), MATLAB Central File Exchange.
Hope it helps.

Community Treasure Hunt

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

Start Hunting!

Translated by