rho: Autocorrelation

View source: R/rho.R

rhoR Documentation

Autocorrelation

Description

Calculate serial autocorrelation with lag 1.

Usage

rho(x)

Arguments

x

a vector of values.

Value

Autocorrelation as a number.

Note

Gives same value as acf(lag=1).

In the calculations, the two vectors x[t] and x[t+1] are compared to the same xbar.

Therefore, the estimated autocorrelation is slightly lower than cor(x[t], x[t+1]) and also lower than cov(x[t], x[t+1]) / var(x), where x[t] and x[t+1] are not compared to a common mean.

This function serves as a shorthand for acf(x, plot=FALSE, lag.max=1)$acf[2] and makes the underlying equation transparent.

See Also

noise.


arnima-github/arni documentation built on Oct. 28, 2023, 6:18 p.m.