time-lagged correlation coefficient between two time series

I am trying to find the time-lagged correlation coefficient between two time series (two sea pressure time series at different points). I have two series of exactly the same length and with the same number of records, and I just want to see at what time lag the two series have the highest correlation. I obtained the correlation coeficient from corr.m but are looking for one that handles lag options to obtain the highest correlation at a given time.
Any help would be appreciated.
Thanks.

3 件のコメント

Kim
Kim 2013 年 2 月 8 日
I would also be very grateful for any input on this question. I have the same problem (but EEG data). I can see in the visual representation that there may be a time lag in the data of about 50 ms. I have tried xcorr with different lags, but am having trouble, 1. figuring out the significance of the return, 2. exactly how to interpret the stem plot. It should probably be obvious but I am uncertain that I have it right. Thanks!
Youssef  Khmou
Youssef Khmou 2013 年 2 月 8 日
hi, did you only use "corr.m"? or you also used "xcorr.m"?
wasswa peter
wasswa peter 2020 年 7 月 26 日
Hello,I think better use R,here is the code I developed to find the time lag between meteorological drought and hydrological drought
library("ggpubr")
library("Kendall")
library("trend")
library("astsa")
my_data <- read.csv(file.choose())
my_data
names(my_data)
attach(my_data)
x <-SPI3
y <-SDI3
SPI3=ts (SPI3)
SDI3 = ts(SDI3)
ccfvalues = ccf(SPI3, SDI3)
ccfvalues
ccf (SPI3, SDI3, main = "SPI3 & SDI3 FOR STATION B",xlab = "Lag Time (months)",ylab= "Autocorrelation")

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

回答 (2 件)

Naomi Krauzig
Naomi Krauzig 2019 年 12 月 12 日

1 投票

In case this is still an open question [r,lags] = xcorr(x,y) also returns the lags at which the correlations are computed.
Youssef  Khmou
Youssef Khmou 2013 年 2 月 8 日
編集済み: Youssef Khmou 2013 年 2 月 8 日

0 投票

hi,i propose two ways :
1)as you have to series P1, P2 of length N both:
y=xcorr(P1,P2); % Len= 2*N-1
plot(y)
2)Or logically, you can compute the quadratic error, as
( P1(i,j)-P2(i,j) )² for 1<=i,j <=N :
err=(P1-P2).^2;
f=1./err;
figure, plot(f), xlabel(' Measurments'), ylabel(' E^2'),
[Max,time_index]=max(f);
The "time_index" is when there is high correlation between p1 and p2 .

カテゴリ

ヘルプ センター および File ExchangeWeather and Atmospheric Science についてさらに検索

製品

質問済み:

2013 年 1 月 23 日

コメント済み:

2020 年 7 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by