Given two series
${x}_{1},{x}_{2},\dots ,{x}_{n}$ and
${y}_{1},{y}_{2},\dots ,{y}_{n}$ the function calculates the crosscorrelations between
${x}_{t}$ and lagged values of
${y}_{t}$:
where
and similarly for
$y$.
The ratio of standard deviations
${s}_{y}/{s}_{x}$ is also returned, and a portmanteau statistic is calculated:
Provided
$n$ is large,
$L$ much less than
$n$, and both
${x}_{t},{y}_{t}$ are samples of series whose true autocorrelation functions are zero, then, under the null hypothesis that the true crosscorrelations between the series are zero,
stat has a
${\chi}^{2}$distribution with
$L$ degrees of freedom. Values of
stat in the upper tail of this distribution provide evidence against the null hypothesis.
 1:
$\mathbf{x}\left[{\mathbf{nxy}}\right]$ – const doubleInput

On entry: the $n$ values of the $x$ series.
 2:
$\mathbf{y}\left[{\mathbf{nxy}}\right]$ – const doubleInput

On entry: the $n$ values of the $y$ series.
 3:
$\mathbf{nxy}$ – IntegerInput

On entry: $n$, the length of the time series.
Constraint:
${\mathbf{nxy}}\ge 2$.
 4:
$\mathbf{nl}$ – IntegerInput

On entry: $L$, the maximum lag for calculating crosscorrelations.
Constraint:
$1\le {\mathbf{nl}}<{\mathbf{nxy}}$.
 5:
$\mathbf{s}$ – double *Output

On exit: the ratio of the standard deviation of the $y$ series to the standard deviation of the $x$ series, ${s}_{y}/{s}_{x}$.
 6:
$\mathbf{r0}$ – double *Output

On exit: the crosscorrelation between the $x$ and $y$ series at lag zero.
 7:
$\mathbf{r}\left[{\mathbf{nl}}\right]$ – doubleOutput

On exit: ${\mathbf{r}}\left[\mathit{l}1\right]$ contains the crosscorrelations between the $x$ and $y$ series at lags $L$, ${r}_{xy}\left(\mathit{l}\right)$, for $\mathit{l}=1,2,\dots ,L$.
 8:
$\mathbf{stat}$ – double *Output

On exit: the statistic for testing for absence of crosscorrelation.
 9:
$\mathbf{fail}$ – NagError *Input/Output

The NAG error argument (see
Section 3.7 in How to Use the NAG Library and its Documentation).
All computations are believed to be stable.
Please consult the
x06 Chapter Introduction for information on how to control and interrogate the OpenMP environment used within this function. Please also consult the
Users' Note for your implementation for any additional implementationspecific information.