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.
acc(x, lag =1)
Arguments
x: a vector, usually residuals.
lag: lag for which the autocorrelation should be calculated.
Returns
Autocorrelation coefficient of lag k, numeric value.
Examples
## Simulate AR(1) Process with 30 observations and positive autocorrelationX <- 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]