Re: [R] acf lag1 value

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Thu, 17 Jan 2008 08:56:53 +0000 (GMT)

Please re-check your time-series books. The acf at lag 1 is _not_ the correlation between x and lag(x). For one thing, the variance of x is computed from the whole series, and not from the series with either the first or last value removed -- there is also the question of the divisor.

See MASS p.390 for the formulae used.

On Thu, 17 Jan 2008, Shubha Vishwanath Karanth wrote:

> Hi R,
>
>
>
> I have doubt.
>
>
>
>> x= c(4,5,6,3,2,4,5)
>
>> acf(x,plot=F,lag.max=1)
>
>
>
> Autocorrelations of series 'x', by lag
>
>
>
> 0 1
>
> 1.000 0.182
>
>
>
> But if I actually calculate the autocorrelation at lag1 I get,

Not the right formula.

>
>
>> cor(x[-1],x[-length(x)])
>
> [1] 0.1921538
>
>
>
> Even in excel I get 0.1921538 value. So, I want to know what the 'acf'
> function is calculating here....
>
>
>
> Thanks in advance,
>
> Shubha Karanth
>
> This e-mail may contain confidential and/or privileged i...{{dropped:13}}
>
> ______________________________________________
> R-help_at_r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
> and provide commented, minimal, self-contained, reproducible code.
>

-- 
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

______________________________________________
R-help_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Thu 17 Jan 2008 - 09:03:05 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Thu 17 Jan 2008 - 12:30:07 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.

list of date sections of archive