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(106.7,101.1,97.8,113.8,107.1,117.5,113.7,106.6,109.8,108.8,102.0,114.5,116.5,108.6,113.9,109.3,112.5,123.4,115.2,110.8,120.4,117.6,111.2,131.1,118.9,115.7,119.6,113.1,106.4,115.5,111.8,109.6,121.5,109.5,109.0,113.4,112.7,114.4,109.2,116.2,113.8,123.6,112.6,117.7,113.3,110.7,114.7,116.9,120.6,111.6,111.9,116.1,111.9,125.1,115.1,116.7,115.8,116.8,113.0,106.5) > x <- c(87.0,96.3,107.1,115.2,106.1,89.5,91.3,97.6,100.7,104.6,94.7,101.8,102.5,105.3,110.3,109.8,117.3,118.8,131.3,125.9,133.1,147.0,145.8,164.4,149.8,137.7,151.7,156.8,180.0,180.4,170.4,191.6,199.5,218.2,217.5,205.0,194.0,199.3,219.3,211.1,215.2,240.2,242.2,240.7,255.4,253.0,218.2,203.7,205.6,215.6,188.5,202.9,214.0,230.3,230.0,241.0,259.6,247.8,270.3,289.7) > par7 = '0' > par6 = '0' > par5 = '1' > par4 = '1' > par3 = '0' > par2 = '1' > par1 = '0.0' > #'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] 0.101560200 0.106294659 0.072906771 -0.082287703 -0.170143420 [6] 0.019912162 0.066726706 0.031268306 0.037997752 -0.099429551 [11] 0.072296104 0.006852694 0.026950621 0.046390507 -0.004543397 [16] 0.066074227 0.012706651 0.100043374 -0.041996840 0.055612784 [21] 0.099331861 -0.008196767 0.120066663 -0.093001412 -0.084223665 [26] 0.096827481 0.033066222 0.137985743 0.002219757 -0.057027993 [31] 0.117261251 0.040404371 0.089597837 -0.003213223 -0.059188871 [36] -0.055151820 0.026953068 0.095629428 -0.038108701 0.019235873 [41] 0.109904081 0.008291921 -0.006212486 0.059279599 -0.009441455 [46] -0.147977415 -0.068763750 0.009284210 0.047492305 -0.134326832 [51] 0.073615240 0.053262768 0.073406792 -0.001303498 0.046717625 [56] 0.074345051 -0.046520016 0.086910484 0.069313451 > y [1] 105.7 100.1 96.8 112.8 106.1 116.5 112.7 105.6 108.8 107.8 101.0 113.5 [13] 115.5 107.6 112.9 108.3 111.5 122.4 114.2 109.8 119.4 116.6 110.2 130.1 [25] 117.9 114.7 118.6 112.1 105.4 114.5 110.8 108.6 120.5 108.5 108.0 112.4 [37] 111.7 113.4 108.2 115.2 112.8 122.6 111.6 116.7 112.3 109.7 113.7 115.9 [49] 119.6 110.6 110.9 115.1 110.9 124.1 114.1 115.7 114.8 115.8 112.0 105.5 > postscript(file="/var/www/html/rcomp/tmp/1ww2r1229880998.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.124 -0.062 -0.053 0.029 0.109 -0.102 -0.286 0.019 0.038 0.097 0.141 -3 -2 -1 0 1 2 3 4 5 6 7 -0.026 -0.163 0.015 -0.060 0.014 0.219 0.031 0.093 0.035 -0.191 0.162 8 9 10 11 12 13 14 0.048 0.004 0.008 0.072 -0.184 -0.032 0.146 > 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/2v9jy1229880998.tab") > > system("convert tmp/1ww2r1229880998.ps tmp/1ww2r1229880998.png") > > > proc.time() user system elapsed 0.392 0.173 0.449