[R] acf lag1 value

Shubha Vishwanath Karanth shubhak at ambaresearch.com
Thu Jan 17 11:52:22 CET 2008


Thank you Professor...

Shubha Karanth | Amba Research
Ph +91 80 3980 8031 | Mob +91 94 4886 4510 
Bangalore * Colombo * London * New York * San José * Singapore * www.ambaresearch.com

-----Original Message-----
From: Prof Brian Ripley [mailto:ripley at stats.ox.ac.uk] 
Sent: Thursday, January 17, 2008 2:27 PM
To: Shubha Vishwanath Karanth
Cc: r-help at stat.math.ethz.ch
Subject: Re: [R] acf lag1 value

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
This e-mail may contain confidential and/or privileged i...{{dropped:10}}




More information about the R-help mailing list