Summary: [S] acf

reinhard@iso.iso.unibas.ch
Fri, 29 May 1998 11:03:55 +0200


For the uninitiated OR students:
V&R p. 353 translates to code like
bsp <- c(100,105,110,120,140,150,160,165,170,175)
acor <- function(s,x){
n <- length(x)
mx <- mean(x)
c0 <- sum((x-mx)^2)/n
cs <- (sum((x[(1+s):n]-mx)*(x[1:(n-s)]-mx)))/n
return(cs/c0)
}
cbind(acf(bsp,plot=F)$acf,
apply(matrix(0:length(bsp),ncol=1),1,acor,bsp))
[,1] [,2]
[1,] 1.0000000 1.0000000
[2,] 0.7527636 0.7527636
[3,] 0.4648356 0.4648355
[4,] 0.1497796 0.1497796
[5,] -0.1486606 -0.1486606
[6,] -0.3324856 -0.3324856
[7,] -0.4451000 -0.4451000
[8,] -0.4213971 -0.4213971
[9,] -0.3295354 -0.3295354
[10,] -0.1902001 -0.1902001
[11,] 0.0000000 NA

(He is not _my_ professor anyway.) Thanks to B. Ripley and C. Keller!
As the series is not stationary, the (non-) differing means are responsible
for the differing results.
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news