# How to calculate the cross correlation between two time series measured at different instants?

I have two time series with measurements of the same type but different stations. I would like to know if the two series are correlated and how much is the "lag" between them. The idea is that in this way I would be able to predict the behavior of a station looking at the other. I have investigated a bit, and I think that the tool I need is the cross correlation. But how can I calculate the cross correlation between two time series if the samples are taken at different instants?

The timespan is the same, let's say Monday to Sunday, but the samples are taken at completely different instants and for a certain t I don't always have a value for both series.

How should I do in this case? All cross correlation formulas require you to have both y(t) and z(t), if y and z are the two series.

• I've faced similar problems in the past, but can't say I have a completely satisfactory answer. Can you put them on approximately the same intervals by taking a subset of one of the timeseries? Not that great an answer, you are losing information. – shf8888 May 31 '15 at 17:39
• You mean I could create the "missing" values on a timeserie by using subset of values and calculating the mean? – Enrico May 31 '15 at 17:54
• The mean could work. Even better might be (depending on the process's variability) to pick the value from the time series with the shorter intervals that is closest to the measurement time on the time series with larger intervals. Depends on the process, of course. For example, suppose timeseries A is measured once a day at noon. Timeseries B, once an hour. Take the values of timeseries B at noon for each day, discard the rest. However, not sure if this is your situation / others may have better ideas that salvage more info from timeseries B. – shf8888 May 31 '15 at 21:09
• This gives me an idea. I could calculate the cross-correlation on the moving averages. The samples are taken every 5 minutes for every station. I could calculate the moving averages using a window of 1 Hour, and then cross-correlate the result. Could this be a good approach? – Enrico Jun 2 '15 at 13:01
• Depends on the process. Ideally (at least in the formulation we're discussing), you're trying to approximate taking a reading at the same time in timeseries_a as in timeseries_b. So, if you're trying to make timeseries_a match the intervals of timeseries_b, the best approach will be domain / dataset specific. By this I mean, would a rolling average more closely help you match up these two timeseries? Or would just taking the closest available measurements in time? – shf8888 Jun 3 '15 at 20:42

The answer is a domain/process specific problem of approximating the expected values for one of the processes (process_a) at the time intervals of measurement of process_b. A few options, in order of increasing sophistication:
1. Take the values of timeseries_a that are closest in time to those observed in timeseries_b. Assumption: the best approximation of process_a at time t is that of the closest measurement in time of process_a.
2. Approximate the values of timeseries_a at the time of measurement of timeseries_b using a weighted average. Assumption: the best approximation of process_a at time t is the weighted average of the measurements of process_a around that time.
3. Model process_a more fully as a regression problem, and make an estimate of the values at the same measurement times as process_b. Assumptions: whatever the assumptions of your models are.