P-value of cross-correlation
조회 수: 19 (최근 30일)
이전 댓글 표시
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?
댓글 수: 0
답변 (2개)
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
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.
댓글 수: 0
참고 항목
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!