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(2218,1855,2187,1852,1570,1851,1954,1828,2251,2277,2085,2282,2266,1878,2267,2069,1746,2299,2360,2214,2825,2355,2333,3016,2155,2172,2150,2533,2058,2160,2259,2498,2695,2799,2945,2930,2318,2540,2570,2669,2450,2842,3439,2677,2979,2257,2842,2546,2455,2293,2379,2478,2054,2272,2351,2271,2542,2304,2194,2722,2395,2146,1894,2548,2087,2063,2481,2476,2212,2834,2148,2598) > x <- c(22780,17351,21382,24561,17409,11514,31514,27071,29462,26105,22397,23843,21705,18089,20764,25316,17704,15548,28029,29383,36438,32034,22679,24319,18004,17537,20366,22782,19169,13807,29743,25591,29096,26482,22405,27044,17970,18730,19684,19785,18479,10698,31956,29506,34506,27165,26736,23691,18157,17328,18205,20995,17382,9367,31124,26551,30651,25859,25100,25778,20418,18688,20424,24776,19814,12738,31566,30111,30019,31934,25826,26835) > par7 = '0' > par6 = '0' > par5 = '-0.1' > par4 = '12' > par3 = '1' > par2 = '0' > par1 = '0.4' > #'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] -2.6493473 2.0845306 -1.5731408 1.7371634 0.8378459 13.4429775 [7] -7.2137437 4.9397573 13.6042713 12.4636287 0.6894497 1.1184306 [13] -9.7770847 -1.5542237 -1.0280455 -5.9613068 4.0414787 -5.5087400 [19] 3.6112667 -8.2361292 -14.3690752 -11.6233258 -0.6698193 6.1629703 [25] -0.0951708 3.3237372 -1.7900329 -7.5893754 -1.8795128 -10.9852880 [31] 4.4825173 8.4922843 10.7705275 1.5042593 10.0665620 -7.6413654 [37] 0.5221104 -3.9198563 -4.0140634 3.1419280 -3.0769202 -5.2922316 [43] -1.6627172 -6.3414835 -7.5597825 -2.8968089 -3.6786769 4.8268558 [49] 6.0725911 3.8050359 5.9546578 9.1695045 6.6770000 12.6856643 [55] 0.8865939 7.5921988 -1.2928800 12.8177042 1.6497001 2.3554028 > y [1] 5.371888 5.288430 5.365369 5.287668 5.209178 5.287413 5.312864 5.281517 [9] 5.378718 5.384022 5.343181 5.385035 5.381786 5.294233 5.381990 5.339592 [17] 5.259812 5.388459 5.400519 5.371053 5.482500 5.399544 5.395224 5.511958 [25] 5.358533 5.362179 5.357455 5.432942 5.337107 5.359608 5.380357 5.426583 [33] 5.461168 5.478321 5.501254 5.498956 5.392253 5.434203 5.439561 5.456766 [41] 5.417701 5.485210 5.570479 5.458125 5.506415 5.379948 5.485210 5.435280 [49] 5.418635 5.387253 5.404206 5.422906 5.336200 5.383008 5.398762 5.382804 [57] 5.434562 5.389460 5.366850 5.465690 5.407286 5.356590 5.298223 5.435638 [65] 5.343627 5.338238 5.423459 5.422536 5.370634 5.483937 5.357023 5.444500 > postscript(file="/var/www/html/freestat/rcomp/tmp/1si981227993390.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.088 -0.131 0.034 -0.031 0.096 0.084 -0.090 -0.050 -0.166 -0.142 -0.026 -3 -2 -1 0 1 2 3 4 5 6 7 -0.082 -0.095 -0.007 -0.132 -0.164 -0.180 -0.147 -0.155 0.022 -0.025 0.106 8 9 10 11 12 13 14 0.131 0.200 0.175 0.374 0.184 0.362 0.348 > dev.off() null device 1 > > #Note: the /var/www/html/freestat/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/html/freestat/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/freestat/rcomp/tmp/24a3m1227993390.tab") > > system("convert tmp/1si981227993390.ps tmp/1si981227993390.png") > > > proc.time() user system elapsed 0.547 0.227 0.611