IMSL Statistics Reference Guide > Time Series and Forecasting > AUTOCORRELATION Function (PV-WAVE Advantage)
  

AUTOCORRELATION Function (PV-WAVE Advantage)
Computes the sample autocorrelation function of a stationary time series.
Usage
result = AUTOCORRELATION(x, lagmax)
Input Parameters
x—One-dimensional array containing the time series. N_ELEMENTS(x) must be greater than or equal to 2.
lagmax—Scalar integer containing the maximum lag of autocovariance, autocorrelations, and standard errors of autocorrelations to be computed. lagmax must be greater than or equal to 1 and less than N_ELEMENTS(x).
Returned Value
result—One-dimensional array of length lagmax + 1 containing the autocorrelations of the time series x. The 0th element of this array is 1. The kth element of this array contains the autocorrelation of lag k where k = 1, ..., lagmax.
Input Keywords
Double—If present and nonzero, double precision is used.
Xmean_In—The estimate of the mean of the time series x.
Se_Option—Method of computation for standard errors of the autocorrelations. Keywords Se_Option and Seac must be used together.
*1Compute the standard errrors of autocorrelation using Barlett’s formula.
*2Compute the standard errrors of autocorrelation using Moran’s formula.
Output Keywords
Acv—Named variable into which an array of length lagmax + 1 containing the variance and autocovariances of the time series x is stored. The 0th element of this array is the variance of the time series x. The kth element contains the autocovariance of lag k where k = 1, ..., lagmax.
Seac—Named variable into which an array of length lagmax containing the standard errors of the autocorrelations of the time series x is stored. Keywords Seac and Se_Option must be used together.
Xmean_Out—Named vaariable into which the estimate of the mean of the time series x is stored.
Discussion
Function AUTOCORRELATION estimates the autocorrelation function of a stationary time series given a sample of n = N_ELEMENTS(x) 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 = lagmax. 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 the keyword Se_Option for the output keyword Seac. 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. Function AUTOCORRELATION computes the estimated autocovariances, estimated autocorrelations, and estimated standard errors of the autocorrelations.
.RUN
PRO print_results, xm, acv, result, seac
   PRINT, 'Mean =', xm
   PRINT, 'Variance =', acv(0)
   PRINT, '      Lag       ACV          AC         SEAC'
   PRINT, '       0', acv(0), result(0)
   FOR j=1L, 20 DO $
   PRINT, j, acv(j), result(j), seac(j - 1)
END
 
lagmax = 20
data = STATDATA(2)
x = data(21:120,1)
result = AUTOCORRELATION(x, lagmax, Acv=acv, Se_Option=1, $
   Seac=seac, Xmean_Out=xm)
print_results, xm, acv, result, seac
This results in the following output:
Mean =      46.9760
Variance =      1382.91
Lag       ACV          AC         SEAC
0 1382.91 1.00000
1 1115.03 0.806293 0.0347834
2 592.004 0.428087 0.0962420
3 95.2974 0.0689109 0.156783
4 -235.952 -0.170620 0.205767
5 -370.011 -0.267560 0.230956
6 -294.255 -0.212780 0.228995
7 -60.4423 -0.0437067 0.208622
8 227.633 0.164604 0.178476
9 458.381 0.331462 0.145727
10 567.841 0.410613 0.134406
11 546.122 0.394908 0.150676
12 398.937 0.288477 0.174348
13 197.757 0.143001 0.190619
14 26.8911 0.0194453 0.195490
15 -77.2807 -0.0558828 0.195893
16 -143.733 -0.103935 0.196285
17 -202.048 -0.146104 0.196021
18 -245.372 -0.177432 0.198716
19 -230.816 -0.166906 0.205359
20 -142.879 -0.103318 0.209387

Version 2017.0
Copyright © 2017, Rogue Wave Software, Inc. All Rights Reserved.