# Autocorrelation from multiple time series samples

I have multiple samples of a time series (for example, the time series might be minutely samples from 12am to 3pm, and I have that for ten different days) and I'd like to compute the autocorrelation function $\rho(k)$ together with confidence intervals.

I can think of two "obvious" things to do:

1. Chain all of the samples together end-to-end and compute the autocorrelation function and confidence intervals for the combined sample.
2. Compute the autocorrelation function for each sample individually. Average the values pointwise to get the total autocorrelation function, and apply a square root rule to get the confidence intervals.

Both of these have disadvantages. Option (1) will have artifacts from where I have joined together the time series, which will become more import as I compute $\rho(k)$ for large $k$. Option (2) seems too ad-hoc - I wouldn't know whether to believe my confidence intervals.

Is there a canonical or correct way to do this?

Yes, there is a correct way and it's simple, too.

By definition, the autocorrelation of a stationary process $X_t$ at lag $dt$ is the correlation between $X_t$ and $X_{t+dt}$. Suppose you have observations of this process $x_{t_0}, x_{t_0+dt}, x_{t_0+2dt}, \ldots, x_{t_0+k_0dt}$ at lag $dt$, another set of observations in a non-overlapping time interval $x_{t_1}, x_{t_1+dt}, x_{t_1+2dt}, \ldots, x_{t_1+k_1dt}$ at lag $dt$ for $t_1 \gt t_0+d_0dt$, and in general you have contiguous observations of samples $x_{t_i}, x_{t_i+dt}, x_{t_i+2dt}, \ldots, x_{t_i+k_idt}$, $i=0, 1, \ldots$ for non-overlapping time intervals. Then the correlation coefficient of the ordered pairs

$$\{(x_{t_i+jdt}, x_{t_i+(j+1)dt})\}$$

for $i=0, 1, \ldots$ and $j=0, 1, k_i-1$ estimates the autocorrelation of $x_t$ at lag $dt$. Compute the standard errors of the correlation exactly as you would compute the standard error for the correlation of any bivariate data set $\{(x_k, y_k)\}$.

The difference between this approach and the one proposed in the question is that pairs spanning two sequences, $(x_{t_j+k_jdt}, x_{t_{j+1}})$, are not included in the calculation. Intuitively they should not be, because in general the time interval between these pairs is not equal to $dt$ and therefore such pairs do not provide direct information about the correlation at lag $dt$.

First of all either way you do it you are assuming each day is the same as any other from 12 noon to 3 PM. Also in time series analysis it is not common to have ensembles of the process. But given the assumptions I think you can treat it like you would with independent individual observations.

Each day can be viewed as providing independent estimates of the acf for a set of lags $1$ to $k$. Then the estimates can be averaged and confidence intervals estimated. A complication would seem to be that for each series the estimate of $\rho(i)$ is correlated with the estimate of $\rho(j)$ for $i\neq j$.

I have stumbled across the same type of problem and I know that people have used your first suggestion in a situation where each sample is a number of residuals from one individual (in mixed effects modelling). See this paper.

The autocorrelation is merely a general measure of dependence between adjacent sample points. In your situation it might be more interesting to look at the actual dependences between specific time points (e,g, the correlations between adjacent sample points may be large in the first hour but decline thereafter and/or it may also be interesting to analyse the correlation between, say, the first and last sample). Is it?

If you have more experiments than ten (you mentioned that only ten days are analysed) you could compute a correlation matrix of the association between the specific time points. I have written about this (yet again in mixed effects modeling) here. A free pre-print of the latter paper is freely available at arxiv.org (Investigations of a compartmental model for leucine kinetics using nonlinear mixed effects models with ordinary and stochastic differential equations). See page 23 for the part on autocorrelation.

EDIT: Oops, I just realised that my suggestion was kind of already mentioned above. Sorry for missing out on that, I wrote my answer offline and couldn't post it in time. In either case it should be mentioned that there is a difference between my suggestion and the one above. In my suggestion you get correlations between specific time points. This may be interesting in many situations and could also be used in case of non-equidistant data. However, a large number of individuals/experiments/sampling days are needed to estimate the correlations and their standard deviations.