Learn R Programming

desk (version 1.1.2)

acc: Autocorrelation Coefficient

Description

Calculates the autocorrelation coefficient between a vector and its k-period lag. This can be used as an estimator for rho in an AR(1) process.

Usage

acc(x, lag = 1)

Value

Autocorrelation coefficient of lag k, numeric value.

Arguments

x

a vector, usually residuals.

lag

lag for which the autocorrelation should be calculated.

References

NIST/SEMATECH e-Handbook of Statistical Methods, http://www.itl.nist.gov/div898/handbook/eda/section3/eda35c.htm.

See Also

lagk, acf.

Examples

Run this code
## Simulate AR(1) Process with 30 observations and positive autocorrelation
X <- ar1sim(n = 30, u0 = 2.0, rho = 0.7, var.e = 0.1)
acc(X$u.sim, lag = 1)

## Equivalent result using acf (stats)
acf(X$u.sim, lag.max = 1, plot = FALSE)$acf[2]

Run the code above in your browser using DataLab