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(200.7,146.5,143.6,141.5,137.5,138.7,135.5,136.4,112.1,109,123.8,151.2,139.2,115.7,147.6,126.1,122.8,137.3,142,137.4,89.4,108,117.7,127.3,121,104.1,119.5,116.7,96.1,125,118.8,114.9,79.3,90.5,87.8,109.4,88.9,97.4,112,86.8,82.9,105.2,89.1,85.5,87.1,85.2,88.2,104,96.4,82.3,114.1,88.9,93.6,101.8,96.6,93.7,68.4,68.7,81.2,85.1,75.4,71.6,83,72.3,90.2,89,84.9,90.9,46.6,55.4,88.7,76,76.9,72.1,90,92.3,78,93.9,84.5,80.4,60.5,75.3,91.5,105.2,92.7) > x <- c(61.5,88.5,93.3,89.2,101.3,97,102.2,100.3,78.2,105.9,119.9,108,77,93.1,109.5,100.4,99,113.9,102.1,101.6,84,110.7,111.6,110.7,73.1,87.5,109.6,99.3,92.1,109.3,94.5,91.4,82.9,103.3,96,104.8,65.8,78.7,100.3,85,94.5,97.9,91.9,87.2,84.4,99.2,105.4,110.9,69.8,86.8,106.7,88.8,96.9,108.1,93.7,94.8,79.8,95.6,107.9,104.9,61.9,85.7,92.4,86.4,99.3,95.5,97,102.1,77.8,105.5,113.2,108.8,66.9,89.3,93.6,92,99.5,98.6,94.6,96.7,75.3,102.5,115.1,104.7,71.4) > par7 = '0' > par6 = '0' > par5 = '1' > par4 = '1' > 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] 60.5 87.5 92.3 88.2 100.3 96.0 101.2 99.3 77.2 104.9 118.9 107.0 [13] 76.0 92.1 108.5 99.4 98.0 112.9 101.1 100.6 83.0 109.7 110.6 109.7 [25] 72.1 86.5 108.6 98.3 91.1 108.3 93.5 90.4 81.9 102.3 95.0 103.8 [37] 64.8 77.7 99.3 84.0 93.5 96.9 90.9 86.2 83.4 98.2 104.4 109.9 [49] 68.8 85.8 105.7 87.8 95.9 107.1 92.7 93.8 78.8 94.6 106.9 103.9 [61] 60.9 84.7 91.4 85.4 98.3 94.5 96.0 101.1 76.8 104.5 112.2 107.8 [73] 65.9 88.3 92.6 91.0 98.5 97.6 93.6 95.7 74.3 101.5 114.1 103.7 [85] 70.4 > y [1] 199.7 145.5 142.6 140.5 136.5 137.7 134.5 135.4 111.1 108.0 122.8 150.2 [13] 138.2 114.7 146.6 125.1 121.8 136.3 141.0 136.4 88.4 107.0 116.7 126.3 [25] 120.0 103.1 118.5 115.7 95.1 124.0 117.8 113.9 78.3 89.5 86.8 108.4 [37] 87.9 96.4 111.0 85.8 81.9 104.2 88.1 84.5 86.1 84.2 87.2 103.0 [49] 95.4 81.3 113.1 87.9 92.6 100.8 95.6 92.7 67.4 67.7 80.2 84.1 [61] 74.4 70.6 82.0 71.3 89.2 88.0 83.9 89.9 45.6 54.4 87.7 75.0 [73] 75.9 71.1 89.0 91.3 77.0 92.9 83.5 79.4 59.5 74.3 90.5 104.2 [85] 91.7 > postscript(file="/var/www/html/freestat/rcomp/tmp/1gcl91228247609.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 -0.013 -0.022 -0.071 0.088 0.154 -0.153 -0.094 0.114 0.287 0.086 0.012 -5 -4 -3 -2 -1 0 1 2 3 4 5 0.037 0.058 0.023 -0.016 0.183 0.163 -0.108 0.004 0.212 0.358 0.183 6 7 8 9 10 11 12 13 14 15 16 0.089 0.088 0.066 0.138 0.081 0.219 0.137 -0.107 0.029 0.163 0.250 > 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/2063n1228247609.tab") > > system("convert tmp/1gcl91228247609.ps tmp/1gcl91228247609.png") > > > proc.time() user system elapsed 0.542 0.215 0.607