Correlation between out of phase signals Say I have a numeric sequence A and a set of sequences B that vary with time.
I suspect that there is a relationship between one or more of the B sequences and sequence A,  that changes in Bn are largely or wholly caused by changes in sequence A.  However there is an unknown time delay between changes in A and their effect on each of the B sequences (they are each out of phase by varying amounts)
I am looking for a means of finding the most closely correlating B to A regardless of the time delay.  What options are available to me? 
** EDIT **
The crux of the problem here is that I have millions of B sequences to test, and there are approx 2 million data points within the lag window that I would like to test over.  Working out a correllation for each B for each possible lag scenario is just going to be too computationally expensive (especially as in reality there will be a more dynamic relationship than just lag between A and B, so I will be looking to test variations of relationships as well).
So what I am looking for is a means of taking the lag out of calculation.

Take a look at dynamic time warping. I think it's just the solution you need. I've used the R package 'dtw' which is described here. http://cran.r-project.org/web/packages/dtw/dtw.pdf
