[R] a question on autocorrelation acf

Duncan Murdoch murdoch.duncan at gmail.com
Fri Apr 30 01:08:12 CEST 2010


On 29/04/2010 6:22 PM, zhenjiang xu wrote:
> Hi R users,
>
> where can I find the equations used by acf function to calculate
> autocorrelation?

See the reference listed in ?acf.

Duncan Murdoch

>  I think I misunderstand acf. Doesn't acf use following
> equation to calculate autocorrelation?
> [image: R(\tau) = \frac{\operatorname{E}[(X_t - \mu)(X_{t+\tau} -
> \mu)]}{\sigma^2}\, ,]
> If it does, then the autocorrelation of a sine function should give a
> cosine; however, the following code gives a cosine-shape function with its
> magnitude decreasing along the lag.
> x = c(1:500)
> x = x/10
> x = sin(x)
> acf(x, type='correlation', lag.max=length(x)-1)
>
>



More information about the R-help mailing list