[R] Re: R-help Digest, Vol 2, Issue 13
Adrian Trapletti
adrian.trapletti at lmttrading.com
Mon Apr 14 10:22:59 CEST 2003
> Subject: [R] Autocovariance and acf
> Date: Sat, 12 Apr 2003 05:17:51 +0200
> From: christianlederer at t-online.de (Christian Lederer)
> Reply-To: lederer at trium.de
> To: R-Help <r-help at stat.math.ethz.ch>
>
> Hi,
>
> i calculated the autocovariance of a vector x of length n, using
>
> result <- acf(x, lag, type="covariance")
>
> and expected, that result$acf would contain the values
> cov(x,x), cov(x[1:(n-1)], x[2:n]) ...
>
> However, acf does not calculate this covariances. Instead
> of cov(x[1:(n-i)], x[(i+1):n]) i am getting
>
> ( (x[1] - m) * (x[i+1]-m) + ... + (x[n-i]-m) * (x[n]-m) ) / n
>
> where m = mean(x).
There are many possibilities to estimate the autocovariance function. acf implements the standard estimator. Your suggestion has some disadvantages: See, e.g., in Lütkepohl (1994), Zeitreihenanalyse, 5. Auflage, pp. 236, and in particular p. 243 (I guess you understand German).
> I anderstand, that for efficiency reasons only the mean of the whole
> vector x is substracted instead of the means of the partial vectors.
> But why does it divide by n instead of n-i?
>
> Christian
best
Adrian
--
Dr. Adrian Trapletti Phone : +41 (0) 1 994 5631
Trapletti Statistical Computing Mobile: +41 (0)76 370 5631
Wildsbergstrasse 31 Fax : +41 (0) 1 994 5631
CH-8610 Uster Email : mailto:a.trapletti at bluewin.ch
Switzerland WWW : http://trapletti.homelinux.com
More information about the R-help
mailing list