Hi R users,
where can I find the equations used by acf function to calculate
autocorrelation? 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)
--
Best,
Zhenjiang
[[alternative HTML version deleted]]
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) > >