I have two variables as time series, one a consequent of the other, I would like to find the average time delay it takes the dependent variable to act on the independent variable. Additionally, I would like to find the range of variance that is associated with the lag time and its respective confidence level. I am unsure how to go about this in a statistically valid way, but I am using Python.

Currently I have used np.diff(np.sign(np.diff(df))) to isolate the relative max & mins of the time series to then try to find the time gap between the subsequent pairs of mins & max but that doesn't seem too valid to me -- thoughts? The out put of the mins & maxes return an array like [0, -2, 0, 2, 0, 0, -2] where -2 is the relative min & 2 is relative max.

Methodological pointers would be greatly appreciated.

Thank you for your time & stay safe!

All the best, RS


1 Answer 1


In a first approach, What you are looking for might be lagged correlation. You shift the trailling time serie by some variable time t and you look at correlation with the first time serie while varying the lag. The value of the lag which yield the biggest correlation is a good candidate for an estimation of time delay betweeen the two.

If you want more advanced statitics like variance (meaning that you have a variable lag) it might get more complex as you would have to identify which peak in the first time serie correspond to wich one in the second. Depending on your format of your time serie it might be easy or not. I would suggest to try a simple approach first : for each peak of your first time serie try to find the corresponding one in the second (first peak that appears after it for exemple). It might get complicated if some peaks overlap or the delay is too variable. Another option is to use more complicated things like Dynamic Time Warping Algorithms.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.