partialAutocorrelation

Computes the sample partial autocorrelation function of a stationary time series.

Synopsis

partialAutocorrelation (lagmax, cf)

Required Arguments

int lagmax (Input)
Maximum lag of partial autocorrelations to be computed.
float cf[] (Input)
Array of length lagmax + 1 containing the autocorrelations of the time series x.

Return Value

An array of length lagmax containing the partial autocorrelations of the time series x.

Description

Function partialAutocorrelation estimates the partial autocorrelations of a stationary time series given the K = lagmax sample autocorrelations

ˆρ(k)

for k=0,1,,K. Consider the AR(k) process defined by

Xt=ϕk1Xt1+ϕk2Xt2++ϕkkXtk+At

where φkj denotes the j‑th coefficient in the process. The set of estimates

{ˆϕkk}

for k=1,,K is the sample partial autocorrelation function. The autoregressive parameters

{ˆϕkj}

for j=1,,k are approximated by Yule-Walker estimates for successive AR(k) models where k=1,,K. Based on the sample Yule-Walker equations

ˆρ(j)=ˆϕk1ˆρ(j1)+ˆϕk2ˆρ(j2)+ˆϕkkˆρ(jk),...j=1,2,,k

a recursive relationship for k=1,,K was developed by Durbin (1960). The equations are given by

ˆϕkk={ˆρ(1)k=1ˆρ(k)k1j=1ˆϕk1,jˆρ(kj)1k1j=1ˆϕk1,jˆρ(j)k=2,K

and

ˆϕkj={ˆϕk1,jˆϕkkˆϕk1,kjj=1,2,,k1ˆϕkkj=k

This procedure is sensitive to rounding error and should not be used if the parameters are near the nonstationarity boundary. A possible alternative would be to estimate {φkk} for successive AR(k) models using least or maximum likelihood. Based on the hypothesis that the true process is AR(p), Box and Jenkins (1976, page 65) note

var{ˆϕkk}1n...kp+1

See Box and Jenkins (1976, pages 82‑84) for more information concerning the partial 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 partialAutocorrelation is used to compute the estimated partial autocorrelations.

from numpy import *
from pyimsl.stat.autocorrelation import autocorrelation
from pyimsl.stat.dataSets import dataSets
from pyimsl.stat.partialAutocorrelation import partialAutocorrelation
from pyimsl.stat.writeMatrix import writeMatrix

nobs = 100
lagmax = 20
x = empty(100)

data = dataSets(2)
for i in range(0, nobs):
    x[i] = data[21 + i, 1]

ac = autocorrelation(x, lagmax)
partial = partialAutocorrelation(lagmax, ac)

writeMatrix("Lag      PACF", partial, column=True)

Output

 
 Lag      PACF
 1       0.8063
 2      -0.6345
 3       0.0783
 4      -0.0586
 5      -0.0009
 6       0.1717
 7       0.1086
 8       0.1100
 9       0.0785
10       0.0792
11       0.0687
12      -0.0378
13       0.0811
14       0.0334
15      -0.0348
16      -0.1306
17      -0.1549
18      -0.1191
19      -0.0162
20      -0.0039