RATS 11
RATS 11

CROSS( options )  series1 series2 start end

Computes cross-correlations or cross-covariances of two series

Wizard

You can use the Time Series—Cross Correlations Wizard to generate cross correlations.

Parameters

series1 , series2

the series for which you want to calculate cross-correlations.

start, end

range to use. By default, the common range of series1 and series2.

 

Two additional parameters used in versions of RATS before 7.0 for specifying the range of lags have been replaced by the FROM and TO options. The old parameters are still recognized, but we recommend that you use the options.

Description

CROSS computes the cross-correlations (or, optionally, the cross-covariances) of series1 and series2. Note that the “lag” refers to the number of periods by which series2 lags series1, that is, the correlation at lag k is the correlation between series1(t) and series2(t-k).

 

The @CROSSCORR procedure uses the CROSS instruction to compute and graph cross-correlations. You’ll probably find it better to use that than CROSS itself.

Options

FROM=lowest lag number [-n]

TO=highest lag number [n]

These set the range of lags for which correlations will be computed. The default values are -n and n where n=min(T/4,2√T).

 

COVARIANCES/[NOCOVARIANCES]

If you use the option COVARIANCES, CROSS computes the cross-covariances rather than the cross-correlations of the series.

 

RESULTS=series for cross correlations/covariances [none]

This lets you save the computed statistics in a data series. RATS saves the results in consecutive entries, with the lowest numbered lag (or highest lead) put into entry 1. For instance, with FROM=-10 and TO=10, the lead 10 value goes into entry 1, lag 0 into entry 11 and lag 10 into entry 21. (The RESULTS option was called CORRS before version 7).

 

QSTATS/[NOQSTATS]

SPAN=width of test intervals [all]

DFC=degrees of freedom correction for test [0]

With QSTATS, CROSS computes Q tests for absence of correlation. If you compute both lags and leads, it will include tests for lags only, leads only and lags and leads combined. If you use SPAN, it will do a series of Q tests, beginning with the tests for intervals 1 to width, –width to –1 and –width to width (subject to your choices of FROM and TO), and increasing the test span by width with each set. Use DFC to correct the degrees of freedom of the Q statistic.

 

[CENTER]/NOCENTER

Use NOCENTER if you want the correlations computed without subtracting means from the data.

 

[PRINT]/NOPRINT

PICTURE="picture code for output"

TITLE="title for output" [“Cross-correlations of xx and yy”]

Unless you use NOPRINT, CROSS displays the computed statistics. PICTURE allows you to control the formatting of the numbers in the output table. Use the TITLE option if you want to provide your own title for the output.

 

ORGANIZATION=ROWS/COLUMNS

The ORGANIZATION option determines whether the output is oriented in rows or in columns. The default is ORG=ROWS except when using the WINDOW option, where it is ORG=COLUMNS.

 

WINDOW="title of window" [unused]

If you use the WINDOW option, the output goes to a (read-only) spreadsheet window with the given title rather than being inserted into the output window or file as text. Each lag is shown on a separate line.

Missing Values

CROSS treats missing values as being equal to the mean of the valid observations.

Variables Defined

%NOBS

number of observations (INTEGER)

%CDSTAT

test statistic for (final) Q test (REAL)

%SIGNIF

significance level for (final) Q test (REAL)

Example

cross(qstats,org=columns,from=-8,to=8) aopc djpc

Sample Output

Cross Correlations of Series AOPC and DJPC


 

   Lag    Cross ACF

       -8   -0.04313

       -7    0.09363

       -6   -0.04262

       -5   -0.03402

       -4   -0.01193

       -3    0.06235

       -2    0.04977

       -1    0.05123

        0    0.04147

        1    0.45823

        2   -0.01912

        3   -0.00305

        4    0.10218

        5    0.08225

        6   -0.01360

        7   -0.12994

        8   -0.03627


 

Ljung-Box Q-Statistics

Lag Range  Statistic Signif Lvl

   1 to 8     62.403   0.000000

 -8 to -1      5.845   0.664611

  -8 to 8     68.681   0.000000


 

Technical Information

CROSS uses the following to estimate the cross-correlation function of x and y:

 

\({\rho _{xy}}\left( k \right) = \frac{{\sum {\left( {{x_t} - \bar x} \right)\left( {{y_{t - k}} - \bar y} \right)} }}{{\sqrt {\sum {{{\left( {{x_t} - \bar x} \right)}^2}\sum {{{\left( {{y_t} - \bar y} \right)}^2}} } } }}\)

 

(optionally, the means aren't subtracted).

 

Notice that there is no correction for “degrees of freedom” even though the numerator will have k fewer terms than the sums in the denominator.

 

The correlations computed with CROSS will differ from those computed with CMOM(CORR) for two reasons:

 

CMOM computes the mean for each lag separately, while CROSS just uses the overall sample mean for x and y.

CMOM restricts the range used for all calculations based upon the lags and leads required. CROSS adjusts each calculation separately.

 

The Ljung–Box Q statistic for lags M1 to M2 is

 

\(Q = T\left( {T + 2} \right)\sum\limits_{M1 \le j \le M2} {\frac{{\hat \rho _{xy}^2(j)}}{{T - \left| j \right|}}} \)

 

For a null hypothesis of no correlation at any lead or lag, Q is asymptotically distributed as a \(\chi ^2\) with M2-M1+1  degrees of freedom.


Also, under a null hypothesis of no correlation at any lead or lag, the asymptotic variance of each of the correlation estimates is 1/T.

 


Copyright © 2025 Thomas A. Doan