Lead Lag Correlations for individual years of 2 arrays of same size in Python

60 Views Asked by At

I have two arrays of the same size x (1900) and y (1900), both are daily data starting from August to Oct for every year. I want to calculate the cross-correlation between these 2 arrays for each year separately and store it in a separate array.

Method 1:

# cross correlation using xcorr()
# function
ax1.xcorr(x, y, usevlines=True,
          maxlags=50, normed=True,
          lw=2)

Method 2:

correlation = signal.correlate(x, y, mode="full")
lags = signal.correlation_lags(x.size, y.size, mode="full")
lag = lags[np.argmax(correlation)]

Both options consider x and y as continuous arrays. Whereas, I want to calculate based on time, for each year separately.

0

There are 0 best solutions below