An embedded and charset-unspecified text was scrubbed... Name: not available URL: <https://stat.ethz.ch/pipermail/r-help/attachments/20111104/e4a1c58a/attachment.pl>
acf?
2 messages · Kevin Burton, Gabor Grothendieck
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