[S] acf

reinhard@iso.iso.unibas.ch
Thu, 28 May 1998 20:17:07 +0200


Today a professor complained that SPSS was not returning the results he
had published as a textbook example. I offered to put things staight
using S+. In fact both SPSS and S+ behaved similarly. Why is the following
a feature? (Excuse the clumsy code %)

> bsp
[1] 100 105 110 120 140 150 160 165 170 175

> acf(bsp,plot=F)$acf

, , 1
[,1]
[1,] 1.0000000
[2,] 0.7527636
[3,] 0.4648356
[4,] 0.1497796
[5,] -0.1486606
[6,] -0.3324856
[7,] -0.4451000
[8,] -0.4213971
[9,] -0.3295354
[10,] -0.1902001
[11,] 0.0000000

> for (i in 1:8){print(cor(bsp,lag(bsp,i)))}
[1] 0.9999999
[1] 0.9999999
[1] 0.9999999
[1] 0.9999999
[1] 0.9999999
[1] 0.9999999
[1] 0.9999999
[1] 0.9999999

> for (i in 1:8){print(cor(bsp[-(1:i)],bsp[-(10:(10-i+1))]))}
[1] 0.9831804
[1] 0.9448445
[1] 0.902651
[1] 0.9156016
[1] 0.9041944
[1] 0.9827077
[1] 1
[1] 1

> for (i in 1:8){print(cov(bsp[-(1:i)],bsp[-(10:(10-i+1))])*10/(var(bsp)*(10-i)
))}
[1] 0.9673712
[1] 0.880141
[1] 0.7141819
[1] 0.4883011
[1] 0.335707
[1] 0.1653103
[1] 0.1017294
[1] 0.07629705
-----------------------------------------------------------------------
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