\Header{ARMAacf}{Compute Theoretical ACF for an ARMA Process}
\keyword{ts}{ARMAacf}
\begin{Description}\relax
Compute the theoretical autocorrelation function or partial
autocorrelation function for an ARMA process.\end{Description}
\begin{Usage}
\begin{verbatim}
ARMAacf(ar = numeric(0), ma = numeric(0), lag.max = r, pacf = FALSE)
\end{verbatim}
\end{Usage}
\begin{Arguments}
\begin{ldescription}
\item[\code{ar}] numeric vector of AR coefficients
\item[\code{ma}] numeric vector of MA coefficients
\item[\code{lag.max}] integer. Maximum lage required. Defaults to
\code{max(p, q+1)}, where \code{p, q} are the numbers of AR and MA
terms respectively.
\item[\code{pacf}] logical. Should the partial autocorrelations be returned?
\end{ldescription}
\end{Arguments}
\begin{Details}\relax
The methods used follow Brockwell \& Davis (1991, section 3.3).  Their
equations (3.3.8) are solved for the autocovariances at lags
\eqn{0, \dots, \max(p, q+1)}{}, and the remaining autocorrelations are
given by a recursive filter.\end{Details}
\begin{Value}
A vector of (partial) autocorrelations, named by the lags.\end{Value}
\begin{References}\relax
Brockwell, P. J. and Davis, R. A. (1991) \emph{Time Series: Theory and
Methods}, Second Edition.  Springer.\end{References}
\begin{SeeAlso}\relax
\code{\Link{arima}}, \code{\Link{ARMAtoMA}}, \code{\Link{filter}}.\end{SeeAlso}
\begin{Examples}
\begin{ExampleCode}
ARMAacf(c(1.0, -0.25), 1.0, lag.max = 10)
## Example from Brockwell & Davis (1991, pp.92-4)
## answer 2^(-n) * (32/3 + 8 * n) /(32/3)
n <- 1:10; 2^(-n) * (32/3 + 8 * n) /(32/3)
ARMAacf(c(1.0, -0.25), 1.0, lag.max = 10, pacf = TRUE)
ARMAacf(c(1.0, -0.25), lag.max = 10, pacf = TRUE)
\end{ExampleCode}
\end{Examples}

