acor: autocorrelation

Description Usage Arguments Value Note Author(s) See Also Examples

Description

autocorrelation of a sequence

Usage

1
acor(X, k = 1, na.rm = FALSE)

Arguments

X

a numeric vector or zoo vector

k

the number of lags for which to compute the autocorrelation. Default: 1

na.rm

a boolean, which if TRUE, indicates that NA values should be removed from the series prior to computing the autocorrelation. Default: FALSE

Value

Returns the lag k autocorrelation of X, e.g., the correlation of X[i] with X[i-k].

Note

It's a bit surprising that this is not a part of the core R distribution, but I can't find it. Perhaps it was thought to be too trivial to include.

Author(s)

Matthew Clegg [email protected]

See Also

acf

Examples

1
2
3
4
5
6
acor(1:10)                # a perfect correlation
acor(rnorm(100))          # should be close to zero
acor(cumsum(rnorm(100)))  # slightly less than one
acor(rar1(1000, a1=0.8))  # slightly less than 0.8
acor(rar1(1000, a1=0.8), k=2)  # about 0.64
acor(rar1(1000, a1=0.8), k=3)  # about 0.51

matthewclegg/egcm documentation built on May 21, 2019, 12:59 p.m.