Chapter 8: Time Series Analysis and Forecasting

ACF

Computes the sample autocorrelation function of a stationary time series.

Required Arguments

X — Vector of length NOBS containing the time series.   (Input)

MAXLAG — Maximum lag of autocovariances, autocorrelations, and standard errors of autocorrelations to be computed.   (Input)
MAXLAG must be greater than or equal to one and less than NOBS.

AC — Vector of length MAXLAG + 1 containing the autocorrelations of the time series X.   (Output)
AC(0) = 1. AC(k) contains the autocorrelation of lag k where k = 1, …, MAXLAG.

Optional Arguments

NOBS — Number of observations in the time series X.   (Input)
NOBS must be greater than or equal to two.
Default: NOBS = size (X,1).

IPRINT — Printing option.   (Input)
Default: IPRINT = 0.

IPRINT

Action

0

 No printing is performed.

1

Prints the mean and variance.

2

Prints the mean, variance, and autocovariances.

3

Prints the mean, variance, autocovariances, autocorrelations, and standard errors of autocorrelations.

ISEOPT — Option for computing standard errors of autocorrelations.   (Input)
Default: ISEOPT = 0.

ISEOPT

Action

0

No standard errors of autocorrelations are computed.

1

Computes standard errors of autocorrelations using Bartlett’s formula.

2

Computes standard errors of autocorrelations using Moran’s formula.

IMEAN — Option for computing the mean.   (Input)
Default: IMEAN = 1.

IMEAN

Action

0

XMEAN is user specified.

1

XMEAN is set to the arithmetic mean of X.

XMEAN — Estimate of the mean of time series X.   (Input, if IMEAN = 0; output,
if IMEAN = 1)

ACV — Vector of length MAXLAG + 1 containing the variance and autocovariances of the time series X.   (Output)
ACV(0) contains the variance of the series X. ACV(k) contains the autocovariance of lag k where k = 1, …, MAXLAG.

SEAC — Vector of length MAXLAG containing the standard errors of the autocorrelations of the time series X.   (Output)

            The standard error of AC(k) is SEAC(k) where k = 1, …, MAXLAG. If ISEOPT = 0, then SEAC may be dimensioned of length 1.

FORTRAN 90 Interface

Generic:                              CALL ACF (X, MAXLAG, AC [,…])

Specific:                             The specific interface names are S_ACF and D_ACF.

FORTRAN 77 Interface

Single:            CALL ACF (NOBS, X, IPRINT, ISEOPT, IMEAN, XMEAN, MAXLAG, ACV, AC, SEAC)

Double:                              The double precision name is DACF.

Description

Routine ACF estimates the autocorrelation function of a stationary time series given a sample of n = NOBS observations {Xt} for t = 1, 2, …, n.

Let

be the estimate of the mean μ of the time series {Xt} where

The autocovariance function σ(k) is estimated by

where K = MAXLAG. Note that

is an estimate of the sample variance. The autocorrelation function ρ(k) is estimated by

Note that

by definition.

The standard errors of the sample autocorrelations may be optionally computed according to argument ISEOPT. One method (Bartlett 1946) is based on a general asymptotic expression for the variance of the sample autocorrelation coefficient of a stationary time series with independent, identically distributed normal errors. The theoretical formula is

where

assumes μ is unknown. For computational purposes, the autocorrelations ρ(k) are replaced by their estimates

for |k| K, and the limits of summation are bounded because of the assumption that ρ(k) = 0 for all k such that |k| > K.

A second method (Moran 1947) utilizes an exact formula for the variance of the sample autocorrelation coefficient of a random process with independent, identically distributed normal errors. The theoretical formula is

where μ is assumed to be equal to zero. Note that this formula does not depend on the autocorrelation function.

Example

Consider the Wolfer Sunspot Data (Anderson 1971, page 660) consisting of the number of sunspots observed each year from 1749 through 1924. The data set for this example consists of the number of sunspots observed from 1770 through 1869. Routine ACF computes the estimated autocovariances, estimated autocorrelations, and estimated standard errors of the autocorrelations.

 

      USE GDATA_INT

      USE ACF_INT

 

      IMPLICIT   NONE

      INTEGER    IPRINT, MAXLAG, NOBS

      PARAMETER  (IPRINT=3, MAXLAG=20, NOBS=100)

!

      INTEGER    IMEAN, ISEOPT, NCOL, NROW

      REAL       AC(0:MAXLAG), ACV(0:MAXLAG), RDATA(176,2), &

                SEAC(MAXLAG), X(NOBS), XMEAN

!

      EQUIVALENCE (X(1), RDATA(22,2))

!                                 Wolfer Sunspot Data for

!                                 years 1770 through 1869

      CALL GDATA (2, RDATA, NROW, NCOL)

!                                 Compute standard errors

      ISEOPT = 1

!                                 Center on arithmetic mean

!                                 USE DEFAULT IMEAN = 1

!                                 Compute sample ACF

      CALL ACF (X, MAXLAG, AC, IPRINT=IPRINT, ISEOPT=ISEOPT)

!

      END

Output

 

Output from ACF/A2F

Mean     =     46.976
Variance =     1382.9

Lag         ACV           AC          SEAC

 0         1382.9      1.00000
 1         1115.0      0.80629      0.03478
 2          592.0      0.42809      0.09624
 3           95.3      0.06891      0.15678
 4         -236.0     -0.17062      0.20577
 5         -370.0     -0.26756      0.23096
 6         -294.3     -0.21278      0.22899
 7          -60.4     -0.04371      0.20862
 8          227.6      0.16460      0.17848
 9          458.4      0.33146      0.14573
10          567.8      0.41061      0.13441
11          546.1      0.39491      0.15068
12          398.9      0.28848      0.17435
13          197.8      0.14300      0.19062
14           26.9      0.01945      0.19549
15          -77.3     -0.05588      0.19589
16         -143.7     -0.10394      0.19629
17         -202.0     -0.14610      0.19602
18         -245.4     -0.17743      0.19872
19         -230.8     -0.16691      0.20536
20         -142.9     -0.10332      0.20939

 

Figure 8-2-Sample Autocorrelation Function



http://www.vni.com/
PHONE: 713.784.3131
FAX:713.781.9260