s-news
[Top] [All Lists]

Summary: [S] acf

To: s-news@wubios.wustl.edu
Subject: Summary: [S] acf
From: reinhard@iso.iso.unibas.ch
Date: Fri, 29 May 1998 11:03:55 +0200
Cc: reinhard@iso.iso.unibas.ch
In-reply-to: "Your message of Thu, 28 May 98 20:10:34 BST." <Pine.GSO.3.96.980528200701.29801C-100000@localhost>
Sender: owner-s-news@wubios.wustl.edu
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

<Prev in Thread] Current Thread [Next in Thread>
  • Summary: [S] acf, reinhard <=