How to calculate correlation between two series with high autocorrelation

11 views (last 30 days)
two series with high autocorrelation, so the degree of freedom is decline. Using t-test to estimate the p-value, they are easy to achieve a high significance level. How to adjusted the correlation coefficient that considers their autocorrelation (degree of freedom)? Or, estimate the significance of p-value? In terms of later, I know a solution than calculate effective sample size, nadj = n.*(1-r1.*r2)./(1+r1.*r2); the r1 and r2 are the lag1 autocorrelations of the two series. This solution calculated a very low effective sample size for a high autocorrelation. make it impossible to correlation. But from the plot, I think the two series are correlate significantly. For a better solution, I want to know if there is some correlation coefficient that adjusted for autocorrelation series? Or, another methods for estimating correlation of two sereies that highly autocorrelated.
I have a two series with length of 99, the r= 0.5282, p=3.19e-8, but they are autocorrelated. Acoording to the effective sample size, which is 2.3247, the adjust p value is 0.845. I think the two series are correlated, but after consider the autocorrelation, they are not correlated.
The following is an example of data, with a shorter length.
data1 =[-0.2433 -0.2509 -0.2539 -0.2522 -0.2462 -0.2358 -0.2214 -0.2032 -0.1817 -0.1571 -0.1297 -0.1000 -0.0682 -0.0346 0.0005 0.0368 0.0740 0.1120 0.1504 0.1891];
data2 =[ -1.0213 -1.0088 -0.9919 -0.9707 -0.9452 -0.9155 -0.8816 -0.8437 -0.8021 -0.7570 -0.7088 -0.6577 -0.6041 -0.5487 -0.4917 -0.4339 -0.3757 -0.3176 -0.2604 -0.2046];
[rho,pval] = corr(data1', data2'); % rho = 0.9933, pval = 2.5766e-18
n = length(data1);
r1 = autocorr(data1,1);
r1 = r1(2);
r2 = autocorr(data2,1);
r2 = r2(2);
nadj = n.*(1-r1.*r2)./(1+r1.*r2); % nadj is effective sample size, nadj = 3.0023
t_stat = rho * sqrt((nadj - 2) / (1 - rho^2));
padj = 2 * (1 - tcdf(abs(t_stat), nadj - 2)); % considering effective sample size,according to t-test, the padj = 0.0734

Answers (1)

Drishti
Drishti on 6 Sep 2024
Hi Time,
The alternative work arounds to estimate the correlation of two highly correlated series are:
  1. Cross-Correlation Function: It is a measure of similarity of two series as a displacement of one relative to another.
  2. Transfer Function Models: Transfer model methods like autoregressive can be utilized to calculate the correlation between two time series.
In MATLAB, you can utilize the ‘xcorr' function to calculate the cross-correlation of two discrete time series.
Please refer to the example demonstrating ‘xcorr’ function:
% Sample time series data
A = [1, 2, 3, 4, 5];
B = [2, 3, 4, 5, 6];
% Calculate cross-correlation
[c, lags] = xcorr(A, B);
For more information, you can refer to the MATLAB Documentation of ‘xcorr’ function.
Hope this helps.

Products


Release

R2021b

Community Treasure Hunt

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

Start Hunting!