RATS 11
RATS 11

Instructions /

CORRELATE Instruction

Home Page

← Previous Next →

CORRELATE( options )   series start end (saveseries)

CORRELATE computes autocorrelations and related functions for a time series. You don't often have to do a CORRELATE instruction by itself, as it is built into quite a few heavily-used procedures such as @BJIDENT and @REGCORRS.

Wizard

You can use the Time Series—Autocorrelations wizard.

Parameters

series

series to analyze

start, end

range to use. By default, the defined range of series

saveseries

series for autocorrelations (or covariances). This parameter still works, but we now recommend using the RESULTS option.

Options

METHOD=YULE/[BURG]

This selects the method used to compute correlations. YULE selects the Yule-Walker method, while BURG, the default choice, selects the Burg algorithm.

 

NUMBER=number of correlations to compute [observations/4]

The default is a function of the number of observations.

 

RESULTS=(output) series for the computed autocorrelations or covariances [none]

PARTIAL=(output) series for computed partial autocorrelations [none]

INVERSE=(output) series for computed inverse autocorrelations [none]

Respectively, these compute and save the autocorrelations, partial autocorrelations, and inverse autocorrelations. However, with the COVARIANCES option, these compute autocovariances, partial autocovariances, and inverse autocovariances.

 

COVARIANCES/[NOCOVARIANCES]

With the COVARIANCES option, CORRELATE computes autocovariances rather than autocorrelations.

 

STDERRS=(output) series for standard errors [none]

Saves the asymptotic standard errors for the autocorrelations in the selected series.

 

[CENTER]/NOCENTER

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

 

QSTATS/[NOQSTATS]

SPAN=width of test intervals [all]

DFC=degrees of freedom correction for Q test(s) [0]

QSTATS performs a Ljung-Box Q test for serial correlation. SPAN (with QSTATS) does a series of Q tests with lags 1 to width, 1 to 2 x width, etc. DFC corrects the degrees of freedom of the Q. If applying to residuals from an ARIMA model, DFC should be the number of ARMA parameters you estimated (BOXJENK defines the variable %NARMA for that).

 

[PRINT]/NOPRINT

PICTURE="picture code for output"

TITLE="Title for output" ["Autocorrelations (covariances) of Series xxxx"]

Unless you use NOPRINT, RATS 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=COLUMNS/ROWS

Determines whether the output is oriented by column or by row. Default is ORG=ROWS except when using the WINDOW option, when it is ORG=COLUMNS.

 

WINDOW="title for window"

If you use the WINDOW option, RATS redirects the output to a spreadsheet-style window with the specified title.

Notes

All the output series (RESULTS, PARTIALS, INVERSE and STDERRS) have the "0" lag in entry 1. While this has value 1 for the first three of these (and zero for STDERRS) unless you use the COVARIANCE option, it makes it easier to do graphs since the difference between (for instance) the theoretical pattern of an AR(1) and ARMA(1,1) depends upon the shape when including the 0 lag.

Variables

%NOBS

number of observations (INTEGER)

%QSTAT

test statistic for (final) Q test (REAL)

%QSIGNIF

significance level for (final) Q test (REAL)

%NDFQ

degrees of freedom for (final) Q test (INTEGER)

Example

The two CORRELATE instructions here, combined with the graph instructions which follow them, are quite similar to what you would get with the @BJIDENT procedure.

 

*

* Enders, Applied Econometric Time Series, 4th edition

* Example from User's Guide Section 2.10

* Interest rate spread

* Pages 88-96

*

open data quarterly.xls

calendar(q) 1960:1

data(format=xls,org=columns) / tbill r5

graph(header="T-Bill and 10-year Bond Rates",key=upleft) 2

# tbill

# r5

*

* Compute spread and first difference of spread:

*

set spread = r5 - tbill

diff spread / dspread


 

spgraph(vfields=2,footer="FIGURE 2.5 Time Path of Interest Rate Spread")

 graph(header="Panel (a): The interest rate spread")

 # spread

 graph(header="Panel (b): First difference of the spread")

 # dspread

spgraph(done)

*

* Compute and graph autocorrelations of the spread itself

*

corr(results=corrs,partial=pcorrs,number=12) spread

graph(footer="Figure 2.6 ACF and PACF of the Spread",key=below,$

   style=bar,nodates,min=-1.0,max=1.0,number=0) 2

# corrs

# pcorrs

*

* Compute and graph autocorrelations for the first difference

*

corr(results=dcorrs,partial=dpcorrs,number=12) dspread

graph(header="Correlations of the first difference of spread",key=below,$

   style=bar,nodates,min=-1.0,max=1.0,number=0) 2

# dcorrs

# dpcorrs

 

Sample Output

This is the output from the first of the two instructions. It includes the autocorrelations and the partial autocorrelations.

 

Correlations of Series SPREAD

Quarterly Data From 1960:01 To 2012:04


 

Autocorrelations

   1        2        3        4        5        6        7        8        9        10

 0.85767  0.67822  0.55009  0.41050  0.27911  0.14868  0.06811  0.03465 -0.03681 -0.13148

   11       12

-0.20294 -0.22614


 

Partial Autocorrelations

   1        2        3        4        5        6        7        8        9        10

 0.85767 -0.21698  0.11225 -0.18776 -0.00333 -0.15107  0.13594  0.00902 -0.17915 -0.12313

   11       12

-0.04777  0.09233


 

The graph generated from the first set of correlations and partial autocorrelations is:


 


Copyright © 2025 Thomas A. Doan