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(83.1,89.6,105.7,110.7,110.4,109,106,100.9,114.3,101.2,109.2,111.6,91.7,93.7,105.7,109.5,105.3,102.8,100.6,97.6,110.3,107.2,107.2,108.1,97.1,92.2,112.2,111.6,115.7,111.3,104.2,103.2,112.7,106.4,102.6,110.6,95.2,89,112.5,116.8,107.2,113.6,101.8,102.6,122.7,110.3,110.5,121.6,100.3,100.7,123.4,127.1,124.1,131.2,111.6,114.2,130.1,125.9,119,133.8,107.5,113.5,134.4,126.8,135.6,139.9,129.8,131,153.1,134.1,144.1,155.9,123.3,128.1,144.3,153,149.9,150.9,141,138.9,157.4,142.9,151.7,161,138.5,135.9,151.5,164,159.1,157,142.1,144.8,152.1,154.6,148.7,157.7,146.7) > x <- c(86.7,87.9,89.8,103,102.7,156.3,95,84.6,106.5,98.7,103.5,110.7,96.2,89.2,97.1,104.8,132.5,154.8,83.6,82.4,103.9,87,93.2,110.5,96.4,76.3,94,103.4,137,150.1,112.6,81.4,113.6,99.6,98.2,118.6,86.8,79.3,98.4,93.6,101,161.2,92.5,99.8,104.1,90.2,99.2,116.5,98.4,90.6,130.5,107.4,106,196.5,107.8,90.5,123.8,114.7,115.3,197,88.4,93.8,111.3,105.9,123.6,171,97,99.2,126.6,103.4,121.3,129.6,110.8,98.9,122.8,120.9,133.1,203.1,110.2,119.5,135.1,113.9,137.4,157.1,126.4,112.2,128.8,136.8,156.5,215.2,146.7,130.8,133.1,154.4,160.4,175.1,145.3) > 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] 85.7 86.9 88.8 102.0 101.7 155.3 94.0 83.6 105.5 97.7 102.5 109.7 [13] 95.2 88.2 96.1 103.8 131.5 153.8 82.6 81.4 102.9 86.0 92.2 109.5 [25] 95.4 75.3 93.0 102.4 136.0 149.1 111.6 80.4 112.6 98.6 97.2 117.6 [37] 85.8 78.3 97.4 92.6 100.0 160.2 91.5 98.8 103.1 89.2 98.2 115.5 [49] 97.4 89.6 129.5 106.4 105.0 195.5 106.8 89.5 122.8 113.7 114.3 196.0 [61] 87.4 92.8 110.3 104.9 122.6 170.0 96.0 98.2 125.6 102.4 120.3 128.6 [73] 109.8 97.9 121.8 119.9 132.1 202.1 109.2 118.5 134.1 112.9 136.4 156.1 [85] 125.4 111.2 127.8 135.8 155.5 214.2 145.7 129.8 132.1 153.4 159.4 174.1 [97] 144.3 > y [1] 82.1 88.6 104.7 109.7 109.4 108.0 105.0 99.9 113.3 100.2 108.2 110.6 [13] 90.7 92.7 104.7 108.5 104.3 101.8 99.6 96.6 109.3 106.2 106.2 107.1 [25] 96.1 91.2 111.2 110.6 114.7 110.3 103.2 102.2 111.7 105.4 101.6 109.6 [37] 94.2 88.0 111.5 115.8 106.2 112.6 100.8 101.6 121.7 109.3 109.5 120.6 [49] 99.3 99.7 122.4 126.1 123.1 130.2 110.6 113.2 129.1 124.9 118.0 132.8 [61] 106.5 112.5 133.4 125.8 134.6 138.9 128.8 130.0 152.1 133.1 143.1 154.9 [73] 122.3 127.1 143.3 152.0 148.9 149.9 140.0 137.9 156.4 141.9 150.7 160.0 [85] 137.5 134.9 150.5 163.0 158.1 156.0 141.1 143.8 151.1 153.6 147.7 156.7 [97] 145.7 > postscript(file="/var/www/html/rcomp/tmp/14md01228153684.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.196 0.269 0.092 0.158 0.420 0.320 0.277 0.319 0.116 0.222 0.515 0.388 0.358 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 0.486 0.269 0.367 0.661 0.538 0.511 0.478 0.235 0.280 0.615 0.464 0.412 0.482 10 11 12 13 14 15 16 0.228 0.283 0.514 0.404 0.348 0.349 0.089 > 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/2ywki1228153684.tab") > > system("convert tmp/14md01228153684.ps tmp/14md01228153684.png") > > > proc.time() user system elapsed 0.398 0.177 0.458