Learn R Programming

FitAR (version 1.94)

PacfDL: Partial Autocorrelations via Durbin-Levinson

Description

Given autocovariances, the partial autocorrelations and/or autoregressive coefficients in an AR may be determined using the Durbin-Levinson algorithm. If the autocovariances are sample autocovariances, this is equivalent to using the Yule-Walker equations. But as noted below our function is more general than the built-in R functions.

Usage

PacfDL(c, LinearPredictor = FALSE)

Arguments

c
autocovariances at lags 0,1,...,p = length(c)-1
LinearPredictor
if TRUE, AR coefficients are also determined using the Yule-Walker method

Value

If LinearPredictor = FALSE, vector of length p = length(c)-1 containing the partial autocorrelations at lags 1,...,p. Otherwise a list with components:
Pacf
vector of partial autocorrelations
ARCoefficients
vector of AR coefficients
ResidualVariance
residual variance for AR(p)

Warning

Stationarity is not tested.

Details

The Durbin-Levinson algorithm is described in many books on time series and numerical methods, for example Percival and Walden (1993, eqn 403).

References

Percival, D.B. and Walden, A.T. (1993). Spectral Analysis For Physical Applications, Cambridge University Press.

See Also

acf, ar

Examples

Run this code
#first define a function to compute the Sample Autocovariances
 sacvf<-function(z, lag.max){
 c(acf(z, plot=FALSE, lag.max=lag.max)$acf)*(length(z)-1)/length(z)
 }
#now compute PACF and also fit AR(7) to SeriesA
 ck<-sacvf(SeriesA, 7)
 PacfDL(ck)
 PacfDL(ck, LinearPredictor = TRUE)
#compare with built-in functions
 pacf(SeriesA, lag.max=7, plot=FALSE)
 ar(SeriesA, lag.max=7, method="yw")
#fit an optimal linear predictor of order 10 to MA(1)
 g<-TacvfMA(0.8,5)
 PacfDL(g, LinearPredictor=TRUE)
#
#Compute the theoretical pacf for MA(1) and plot it
 ck<-c(1,-0.4,rep(0,18))
 AcfPlot(PacfDL(ck)$Pacf)
 title(main="Pacf of MA(1), r(1)=-0.4")

Run the code above in your browser using DataLab