Rev 39345 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed
\name{acf}\alias{acf}\alias{ccf}\alias{pacf}\alias{pacf.default}\alias{[.acf}\title{Auto- and Cross- Covariance and -Correlation Function Estimation}\description{The function \code{acf} computes (and by default plots) estimates ofthe autocovariance or autocorrelation function. Function \code{pacf}is the function used for the partial autocorrelations. Function\code{ccf} computes the cross-correlation or cross-covariance of twounivariate series.}\usage{acf(x, lag.max = NULL,type = c("correlation", "covariance", "partial"),plot = TRUE, na.action = na.fail, demean = TRUE, \dots)pacf(x, lag.max, plot, na.action, \dots)\method{pacf}{default}(x, lag.max = NULL, plot = TRUE, na.action = na.fail,...)ccf(x, y, lag.max = NULL, type = c("correlation", "covariance"),plot = TRUE, na.action = na.fail, \dots)\method{[}{acf}(x, i, j)}\arguments{\item{x, y}{a univariate or multivariate (not \code{ccf}) numeric timeseries object or a numeric vector or matrix, or an \code{"acf"} object.}\item{lag.max}{maximum number of lags at which to calculate the acf.Default is \eqn{10\log_{10}(N/m)}{10*log10(N/m)} where \eqn{N} is thenumber of observations and \eqn{m} the number of series.}\item{type}{character string giving the type of acf to be computed.Allowed values are\code{"correlation"} (the default), \code{"covariance"} or\code{"partial"}.}\item{plot}{logical. If \code{TRUE} (the default) the acf is plotted.}\item{na.action}{function to be called to handle missingvalues. \code{na.pass} can be used.}\item{demean}{logical. Should the covariances be about the samplemeans?}\item{\dots}{further arguments to be passed to \code{plot.acf}.}\item{i}{a set of lags (time differences) to retain.}\item{j}{a set of series (names or numbers) to retain.}}\value{An object of class \code{"acf"}, which is a list with the followingelements:\item{lag}{A three dimensional array containing the lags at whichthe acf is estimated.}\item{acf}{An array with the same dimensions as \code{lag} containingthe estimated acf.}\item{type}{The type of correlation (same as the \code{type}argument).}\item{n.used}{The number of observations in the time series.}\item{series}{The name of the series \code{x}.}\item{snames}{The series names for a multivariate time series.}The result is returned invisibly if \code{plot} is \code{TRUE}.}\details{For \code{type} = \code{"correlation"} and \code{"covariance"}, theestimates are based on the sample covariance.By default, no missing values are allowed. If the \code{na.action}function passes through missing values (as \code{na.pass} does), thecovariances are computed from the complete cases. This means that theestimate computed may well not be a valid autocorrelation sequence,and may contain missing values. Missing values are not allowed whencomputing the PACF of a multivariate time series.The partial correlation coefficient is estimated by fittingautoregressive models of successively higher orders up to\code{lag.max}.The generic function \code{plot} has a method for objects of class\code{"acf"}.The lag is returned and plotted in units of time, and not numbers ofobservations.There are \code{print} and subsetting methods for objects of class\code{"acf"}.}\author{Original: Paul Gilbert, Martyn Plummer.Extensive modifications and univariate case of \code{pacf} byB.D. Ripley.}\seealso{\code{\link{plot.acf}}, \code{\link{ARMAacf}} for the exactautocorrelations of a given ARMA process.}\examples{## Examples from Venables & Ripleyacf(lh)acf(lh, type = "covariance")pacf(lh)acf(ldeaths)acf(ldeaths, ci.type = "ma")acf(ts.union(mdeaths, fdeaths))ccf(mdeaths, fdeaths, ylab="cross-correlation") # just the cross-correlations.presidents # contains missing valuesacf(presidents, na.action = na.pass)pacf(presidents, na.action = na.pass)}\keyword{ts}