Your understanding is wrong. For a start, there is no function acf()
in package tseries: it is in stats.
And the autocorrelation at lag one is not the correlation omitting the
first and last values: it uses the mean and variance estimated from
the whole series and divisor n.
Have you looked at the reference given on ?acf ? As the help says
(This contains the exact definitions used.)
Neither the R help pages nor R-help are intended as tutorials in
statistics.
On Wed, 24 Aug 2011, Vincy Pyne wrote:
> Dear R list
>
> I am trying to understand the auto-correlation concept.
> Auto-correlation is the self-correlation of random variable X with a
> certain time lag of say t.
>
> The article
>
"http://www.mit.tut.fi/MIT-3010/luentokalvot/lk10-11/MDA_lecture16_11.pdf"
> (Page no. 9 and 10) gives the methodology as under.
But that is not the definitive reference, and no, it doesn't (and what
it does give is not the conventional definition in the time series
literature).
> Suppose you have a time series observations as say
>
> X = c(44,41,46,49,49,50,40,44,49,41)
>
> # For autocorrelation with time lag of 1 we define
>
> A = c(41,46,49,49,50,40,44,49,41)?? # first element of X not considered
> B = c(44,41,46,49,49,50,40,44,49) # Last element of X not considered
>
>> cor(A,B)
> [1] -0.02581234
>
> However, if I try the acf command using library tseries I get
>
> acf(X, 1)
>
> Autocorrelations of series ???X???, by
> lag
>
> ???????? 0?????????? 1
> ??1.000 -0.019
>
> So by usual correlation command (where same random variable X is
> converted into two series with a time lag of 1), I obtain
> auto-correlation as -0.02581234 and by acf command I get
> auto-correlation = -0.019 (for time lag of 1).
>
> I am not able to figure out where I am going wrong or is it my
> understanding of auto-correlation procedure is wrong?
>
> Will be grateful if someone guides .
>
> Vincy
>
>
>
> [[alternative HTML version deleted]]
>
>
--
Brian D. Ripley, ripley at stats.ox.ac.uk
Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/
University of Oxford, Tel: +44 1865 272861 (self)
1 South Parks Road, +44 1865 272866 (PA)
Oxford OX1 3TG, UK Fax: +44 1865 272595