R version 2.8.0 (2008-10-20) 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(41,35,34,36,39,40,30,33,30,32,41,40,41,40,39,34,34,46,45,44,40,39,37,39,35,26,26,33,27,30,26,27,18,19,13,14,41,21,16,17,9,14,14,16,11,10,6,9,5,7,2,0,8,13,11,19,23,23,43,59) > 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.3' > 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] -0.47080485 -0.08385804 0.16605528 0.23737625 0.07627739 -0.83353677 [7] 0.26822507 -0.26822507 0.18078670 0.72770403 -0.07495397 0.07495397 [13] -0.07495397 -0.07627739 -0.40343154 0.00000000 0.91137053 -0.06908797 [19] -0.07017119 -0.29240243 -0.07627739 -0.15676213 0.15676213 -0.31957350 [25] -0.82627419 0.00000000 0.65681338 -0.55594418 0.28771912 -0.38858831 [31] 0.10086920 -1.02616368 0.12973069 -0.86763879 0.16176501 2.79851663 [37] -1.84687529 -0.65093013 0.14055308 -1.35460196 0.91333767 0.00000000 [43] 0.30071121 -0.81420099 -0.19291366 -0.94497485 0.73804062 -1.04175149 [49] 0.57377789 -1.87215183 -4.10381471 6.22021994 0.97529287 -0.35172477 [55] 1.21936356 0.47565340 0.00000000 1.76314130 1.02556094 > postscript(file="/var/www/html/rcomp/tmp/15uy81228769222.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.033 -0.064 0.094 -0.289 -0.054 -0.122 -0.035 -0.065 -0.038 -0.211 0.059 -3 -2 -1 0 1 2 3 4 5 6 7 0.000 0.126 0.058 -0.379 0.154 0.000 -0.020 0.194 0.000 -0.125 0.061 8 9 10 11 12 13 14 0.008 -0.045 0.119 -0.049 0.000 0.016 -0.006 > 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/20pei1228769222.tab") > > system("convert tmp/15uy81228769222.ps tmp/15uy81228769222.png") > > > proc.time() user system elapsed 0.398 0.178 0.491