Description Usage Arguments Details Value Warning Note Author(s) References See Also Examples
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.
1 |
c |
autocovariances at lags 0,1,...,p = length(c)-1 |
LinearPredictor |
if TRUE, AR coefficients are also determined using the Yule-Walker method |
The Durbin-Levinson algorithm is described in many books on time series and numerical methods, for example Percival and Walden (1993, eqn 403).
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) |
Stationarity is not tested.
Sample partial autocorrelations can also be computed with the
acf
function and Yule-Walker estimates can
be computed with the ar
function.
Our function PacfDL
provides more flexibility since
then input c may be any valid autocovariances not just the usual
sample autocovariances. For example, we can determine the minimum
mean square error one-step ahead linear predictor of order p for
theoretical autocovariances from a fractional arma or other linear
process.
A.I. McLeod and Y. Zhang
Percival, D.B. and Walden, A.T. (1993). Spectral Analysis For Physical Applications, Cambridge University Press.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | #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")
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.