[R] acf?
Gabor Grothendieck
ggrothendieck at gmail.com
Sat Nov 5 06:13:16 CET 2011
On Sat, Nov 5, 2011 at 12:26 AM, Kevin Burton <rkevinburton at charter.net> wrote:
> I started to check what I thought I knew with autocovariance and it doesn’t
> jive with the the calculations given by ‘R’. I was wondering if there is
> some scaling or something that I am not aware of.
>
>
>
> Take the example
>
>
>
> Ø d <- 1:10
>
> Ø (a <- acf(d, type="covariance", demean=FALSE, plot=FALSE))
>
>
>
> Autocovariances of series ‘d’, by lag
>
>
>
> 0 1 2 3 4 5 6 7 8 9
>
> 38.5 33.0 27.6 22.4 17.5 13.0 9.0 5.6 2.9 1.0
>
>
>
> But when I calculate it manually (for lag of 1) like:
>
>
>
> Ø y1 <- d – mean(d)
>
> Ø dl <- c(d[-1], d[1])
>
> Ø y2 <- dl – mean(d)
>
> Ø mean(y1*y2)
>
> [1] 3.75
>
>
>
> What am I missing to get this basic concept? Isn’t it E[(Yt – ut)(Ys – us)]?
>
Try this:
> d <- 1:10
> dm <- d - mean(d)
> sum(dm[-1] * dm[-10]) / 10
[1] 5.775
> acf(d, type = "cov", plot = FALSE)[1]
Autocovariances of series ‘d’, by lag
1
5.78
--
Statistics & Software Consulting
GKX Group, GKX Associates Inc.
tel: 1-877-GKX-GROUP
email: ggrothendieck at gmail.com
More information about the R-help
mailing list