R version 2.7.0 (2008-04-22) Copyright (C) 2008 The R Foundation for Statistical Computing ISBN 3-900051-07-0 R is free software and comes with ABSOLUTELY NO WARRANTY. You are welcome to redistribute it under certain conditions. Type 'license()' or 'licence()' for distribution details. R is a collaborative project with many contributors. Type 'contributors()' for more information and 'citation()' on how to cite R or R packages in publications. Type 'demo()' for some demos, 'help()' for on-line help, or 'help.start()' for an HTML browser interface to help. Type 'q()' to quit R. > y <- c(0,9,1,4,6,21,24,23,22,21,20,16,18,18,24,16,15,24,18,15,4,3,6,5,12,12,12,14,12,17,12,20,21,15,22,19,19,26,25,19,20,30,31,35,33,26,25,17,14,8,12,7,4,10,8,16,14,20,9,10) > x <- c(34,39,40,45,43,42,49,43,50,44,40,41,45,45,48,54,47,35,28,28,34,23,33,38,41,47,46,45,47,49,50,56,50,56,58,59,51,59,60,60,68,62,62,58,56,50,52,36,33,26,28,27,20,16,11,0,3,10,0,3) > par7 = '0' > par6 = '1' > par5 = '0.9' > par4 = '12' > par3 = '0' > par2 = '1' > par1 = '1.5' > #'GNU S' R Code compiled by R2WASP v. 1.0.44 () > #Author: Prof. Dr. P. Wessa > #To cite this work: Wessa P., (2008), Cross Correlation Function (v1.0.6) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_cross.wasp/ > #Source of accompanying publication: Office for Research, Development, and Education > #Technical description: > par1 <- as.numeric(par1) > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > par4 <- as.numeric(par4) > par5 <- as.numeric(par5) > par6 <- as.numeric(par6) > par7 <- as.numeric(par7) > if (par1 == 0) { + x <- log(x) + } else { + x <- (x ^ par1 - 1) / par1 + } > if (par5 == 0) { + y <- log(y) + } else { + y <- (y ^ par5 - 1) / par5 + } > if (par2 > 0) x <- diff(x,lag=1,difference=par2) > if (par6 > 0) y <- diff(y,lag=1,difference=par6) > if (par3 > 0) x <- diff(x,lag=par4,difference=par3) > if (par7 > 0) y <- diff(y,lag=par4,difference=par7) > x [1] 30.201705 6.284861 32.591309 -13.266214 -6.519165 47.205927 [7] -40.686762 47.722356 -41.126939 -25.920512 6.363921 26.227389 [13] 0.000000 20.456385 42.842389 -49.734381 -76.768649 -39.267146 [19] 0.000000 33.393527 -58.632160 52.844295 29.784777 18.853574 [25] 39.791782 -6.819058 -6.745335 13.564393 13.856156 7.035594 [31] 43.674824 -43.674824 43.674824 15.099475 7.648506 -59.316500 [37] 59.316500 7.713602 0.000000 63.989576 -48.369251 0.000000 [43] -30.982432 -15.099475 -43.674824 14.282628 -105.984888 -17.619622 [49] -37.997373 10.391711 -5.243972 -33.902264 -16.961813 -18.344752 [55] -24.321915 3.464102 17.617749 -21.081851 3.464102 > y [1] 8.0274156 -6.9163045 2.7580025 1.7039451 11.6359105 2.1975484 [7] -0.7292842 -0.7324630 -0.7358011 -0.7393147 -2.9966183 1.5066511 [13] 0.0000000 4.4268303 -5.9334813 -0.7602827 6.6937641 -4.4268303 [19] -2.2669338 -8.8436398 -0.8825854 2.5865305 -0.8433924 5.6700290 [25] 0.0000000 0.0000000 1.5476860 -1.5476860 3.8288835 -3.8288835 [31] 6.0699592 0.7393147 -4.4962157 5.2320169 -2.2181380 0.0000000 [37] 5.1294871 -0.7233509 -4.4061362 0.7430222 7.2531823 0.7105132 [43] 2.8199271 -1.4056882 -4.9914695 -0.7233509 -5.9041898 -2.2811974 [49] -4.7273600 3.1796739 -3.9972521 -2.5333295 4.9567557 -1.6058480 [55] 6.2530148 -1.5256549 4.5222732 -8.4422388 0.7984537 > postscript(file="/var/www/html/rcomp/tmp/1g8rj1229264330.ps",horizontal=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > (r <- ccf(x,y,main='Cross Correlation Function',ylab='CCF',xlab='Lag (k)')) Autocorrelations of series 'X', by lag -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -0.189 0.094 -0.114 0.195 -0.142 0.151 -0.211 -0.068 0.036 -0.161 0.268 -3 -2 -1 0 1 2 3 4 5 6 7 0.150 0.248 0.006 0.132 0.084 0.071 0.156 -0.267 -0.037 0.081 0.001 8 9 10 11 12 13 14 0.089 0.087 -0.059 -0.055 -0.184 -0.147 0.054 > dev.off() null device 1 > > #Note: the /var/www/html/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/rcomp/createtable") > > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Cross Correlation Function',2,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Parameter',header=TRUE) > a<-table.element(a,'Value',header=TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Box-Cox transformation parameter (lambda) of X series',header=TRUE) > a<-table.element(a,par1) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Degree of non-seasonal differencing (d) of X series',header=TRUE) > a<-table.element(a,par2) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Degree of seasonal differencing (D) of X series',header=TRUE) > a<-table.element(a,par3) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Seasonal Period (s)',header=TRUE) > a<-table.element(a,par4) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Box-Cox transformation parameter (lambda) of Y series',header=TRUE) > a<-table.element(a,par5) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Degree of non-seasonal differencing (d) of Y series',header=TRUE) > a<-table.element(a,par6) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Degree of seasonal differencing (D) of Y series',header=TRUE) > a<-table.element(a,par7) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'k',header=TRUE) > a<-table.element(a,'rho(Y[t],X[t+k])',header=TRUE) > a<-table.row.end(a) > mylength <- length(r$acf) > myhalf <- floor((mylength-1)/2) > for (i in 1:mylength) { + a<-table.row.start(a) + a<-table.element(a,i-myhalf-1,header=TRUE) + a<-table.element(a,r$acf[i]) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/www/html/rcomp/tmp/26qfc1229264330.tab") > > system("convert tmp/1g8rj1229264330.ps tmp/1g8rj1229264330.png") > > > proc.time() user system elapsed 2.027 0.499 2.931