autocov(y [, nlags [, nfreq]] [,full:T] [center:T] [,degree:d]), y a REAL vector or matrix, nlags > 0 and nfreq > 0 integers, d an integer scalar or vector. |

c_y <- autocov(y, nlags) computes sample autocovariances acvf(h,y) (y a REAL vector) or acvf(h,y[,j]) (y a REAL matrix) for lags h = 0, 1, ..., nlags. The columns of y, which may have no MISSING elements, are interpreted as time series defined at equally spaced time points. For a vector y of length N, the sample autocovariances are defined as acvf(h, y) = sum((y[i] - ybar)*(y[i+h] - ybar),i=1,...,N-h)/N where ybar = sum(y)/N is the sample mean of y. When ny = ncols(y) = 1, c_y is a vector of length L = nlags + 1 with c_y[k] = acvf(k-1,y). When ny > 1, c_y is a L by ny matrix with c_y[k,j] = acvf(k-1,y[,j]). autocov(y) is the same as autocov(y, nrows(y) - 1), computing all non-degenerate sample autocovariances. You can specify that columns of y be detrended by subtracting a polynomial in time using keyword phrase 'degree:d', where d is an integer scalar or vector of length ny = ncols(y). A scalar d is interpreted as rep(d,ny). c_y <- autocov(y [,nlags] degree:d) computes autocovariances of the residuals from polynomial trends fit by least squares to each column of y. The values of the fitted polynomial replace ybar in the definition of acvf(). d[j] is the degree of the polynomial fit to column j. When d[j] = 0, only the sample mean is subtracted (default). When d[j] < 0, nothing is subtracted. You can modify the behavior of autocov() using keyword phrases 'full:T' (compute acvf for negative lags, with acvf(-h,y) in row 2*nlags+2-h), and 'center:T' (same, but with acvf(0,y) in row nlags+1). See crosscov() for details. Autocovariances are computed using crosscov() which makes use of discrete Fourier transforms (DFTs) of length goodfactors(N+nlags), the smallest integer >= N + nlags which has no prime factors > 29. See topic 'fourier'. autocov(y, nlags, M) where M is an integer, does the same, using DFTs of length M. It is an error if M < N + nlags or if M has a prime factor > 29. See topic 'fourier'. You can use macro tsplot() to plot the computed autocovariances. Any of the following might be appropriate to plot the first 50 autocorrelations of the columns of y. Cmd> tsplot(autocov(y, 50), 0) # line plot Cmd> tsplot(autocov(y, 50), 0, impulse:T) # impulse plot Cmd> tsplot(autocov(y, 50), 0, impulse:T, lines:T) # impulse and lines Cmd> tsplot(autocov(y, 50), 0, char:charVec) # plot lines & symbols See also autocor(), crosscov(), crosscor(), tsplot().

Gary Oehlert 2003-01-15