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(103.1,102.5,101.3,99.5,99.4,98.8,99.9,99.9,101.2,97.7,97,99.5,100.3,98.5,95.1,93.1,92.2,89,86.4,84.5,82.7,80.8,81.8,81.8,82.9,83.8,86.2,86.1,86.2,88.8,89.6,87.8,88.3,88.6,91,91.5,95.4,98.7,99.9,98.6,100.3,100.2,100.4,101.4,103,109.1,111.4,114.1,121.8,127.6,129.9,128,123.5,124,127.4,127.6,128.4,131.4,135.1,134,144.5,147.3,150.9,148.7,141.4,138.9,139.8,145.6,147.9,148.5,151.1,157.5,167.5,172.3,173.5,187.5,205.5,195.1,204.5,204.5,201.7,207,206.6,210.6,211.1,215,223.9,238.2,238.9,229.6,232.2,222.1,221.6,227.3,221,213.6) > x <- c(105.3,103,103.8,103.4,105.8,101.4,97,94.3,96.6,97.1,95.7,96.9,97.4,95.3,93.6,91.5,93.1,91.7,94.3,93.9,90.9,88.3,91.3,91.7,92.4,92,95.6,95.8,96.4,99,107,109.7,116.2,115.9,113.8,112.6,113.7,115.9,110.3,111.3,113.4,108.2,104.8,106,110.9,115,118.4,121.4,128.8,131.7,141.7,142.9,139.4,134.7,125,113.6,111.5,108.5,112.3,116.6,115.5,120.1,132.9,128.1,129.3,132.5,131,124.9,120.8,122,122.1,127.4,135.2,137.3,135,136,138.4,134.7,138.4,133.9,133.6,141.2,151.8,155.4,156.6,161.6,160.7,156,159.5,168.7,169.9,169.9,185.9,190.8,195.8,211.9) > par7 = '0' > par6 = '0' > par5 = '1' > par4 = '12' > par3 = '0' > par2 = '0' > par1 = '1' > #'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] 104.3 102.0 102.8 102.4 104.8 100.4 96.0 93.3 95.6 96.1 94.7 95.9 [13] 96.4 94.3 92.6 90.5 92.1 90.7 93.3 92.9 89.9 87.3 90.3 90.7 [25] 91.4 91.0 94.6 94.8 95.4 98.0 106.0 108.7 115.2 114.9 112.8 111.6 [37] 112.7 114.9 109.3 110.3 112.4 107.2 103.8 105.0 109.9 114.0 117.4 120.4 [49] 127.8 130.7 140.7 141.9 138.4 133.7 124.0 112.6 110.5 107.5 111.3 115.6 [61] 114.5 119.1 131.9 127.1 128.3 131.5 130.0 123.9 119.8 121.0 121.1 126.4 [73] 134.2 136.3 134.0 135.0 137.4 133.7 137.4 132.9 132.6 140.2 150.8 154.4 [85] 155.6 160.6 159.7 155.0 158.5 167.7 168.9 168.9 184.9 189.8 194.8 210.9 > y [1] 102.1 101.5 100.3 98.5 98.4 97.8 98.9 98.9 100.2 96.7 96.0 98.5 [13] 99.3 97.5 94.1 92.1 91.2 88.0 85.4 83.5 81.7 79.8 80.8 80.8 [25] 81.9 82.8 85.2 85.1 85.2 87.8 88.6 86.8 87.3 87.6 90.0 90.5 [37] 94.4 97.7 98.9 97.6 99.3 99.2 99.4 100.4 102.0 108.1 110.4 113.1 [49] 120.8 126.6 128.9 127.0 122.5 123.0 126.4 126.6 127.4 130.4 134.1 133.0 [61] 143.5 146.3 149.9 147.7 140.4 137.9 138.8 144.6 146.9 147.5 150.1 156.5 [73] 166.5 171.3 172.5 186.5 204.5 194.1 203.5 203.5 200.7 206.0 205.6 209.6 [85] 210.1 214.0 222.9 237.2 237.9 228.6 231.2 221.1 220.6 226.3 220.0 212.6 > postscript(file="/var/www/html/rcomp/tmp/1f9yk1228237262.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 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 0.386 0.404 0.428 0.454 0.482 0.509 0.537 0.562 0.582 0.605 0.637 0.670 0.703 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 0.744 0.787 0.834 0.891 0.882 0.868 0.843 0.822 0.800 0.767 0.733 0.691 0.647 10 11 12 13 14 15 16 0.612 0.581 0.551 0.520 0.488 0.451 0.417 > 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/2vd521228237263.tab") > > system("convert tmp/1f9yk1228237262.ps tmp/1f9yk1228237262.png") > > > proc.time() user system elapsed 0.386 0.176 0.459