R version 2.7.0 (2008-04-22) 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(377.2,332.2,364.8,352.4,341.6,298.2,355.3,330.9,314.5,418.9,433.2,367,422.9,352.1,419.8,432.7,414.2,387.7,297.2,357.4,384.2,425.2,385.3,355.4,409.8,421.2,421.8,464.2,494,404.2,411.4,403.4,403.3,520.9,439.8,434.8,476.5,454.3,522,498.4,439.9,450.7,447.1,451.3,466.8,498,533.6,451.9,477.1,410.4,469.5,485.4,406.7,439.7,412.2,440.2,411.1,477.7,463.2,320.5) > x <- c(109.57,107.08,110.33,110.36,106.5,104.3,107.21,109.34,108.2,109.86,108.68,113.38,117.12,116.23,114.75,115.81,115.86,117.8,117.11,116.31,118.38,121.57,121.65,124.2,126.12,128.6,128.16,130.12,135.83,138.05,134.99,132.38,128.94,128.12,127.84,132.43,134.13,134.78,133.13,129.08,134.48,132.86,134.08,134.54,134.51,135.97,136.09,139.14,135.63,136.55,138.83,138.84,135.37,132.22,134.75,135.98,136.06,138.05,139.59,140.58) > 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] 108.57 106.08 109.33 109.36 105.50 103.30 106.21 108.34 107.20 108.86 [11] 107.68 112.38 116.12 115.23 113.75 114.81 114.86 116.80 116.11 115.31 [21] 117.38 120.57 120.65 123.20 125.12 127.60 127.16 129.12 134.83 137.05 [31] 133.99 131.38 127.94 127.12 126.84 131.43 133.13 133.78 132.13 128.08 [41] 133.48 131.86 133.08 133.54 133.51 134.97 135.09 138.14 134.63 135.55 [51] 137.83 137.84 134.37 131.22 133.75 134.98 135.06 137.05 138.59 139.58 > y [1] 376.2 331.2 363.8 351.4 340.6 297.2 354.3 329.9 313.5 417.9 432.2 366.0 [13] 421.9 351.1 418.8 431.7 413.2 386.7 296.2 356.4 383.2 424.2 384.3 354.4 [25] 408.8 420.2 420.8 463.2 493.0 403.2 410.4 402.4 402.3 519.9 438.8 433.8 [37] 475.5 453.3 521.0 497.4 438.9 449.7 446.1 450.3 465.8 497.0 532.6 450.9 [49] 476.1 409.4 468.5 484.4 405.7 438.7 411.2 439.2 410.1 476.7 462.2 319.5 > postscript(file="/var/www/html/rcomp/tmp/1cl4x1228246364.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 -3 -2 0.195 0.252 0.238 0.287 0.324 0.319 0.381 0.400 0.422 0.468 0.534 0.587 0.584 -1 0 1 2 3 4 5 6 7 8 9 10 11 0.628 0.662 0.709 0.683 0.635 0.607 0.542 0.494 0.481 0.482 0.450 0.391 0.381 12 13 14 0.368 0.364 0.318 > 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/2jjqo1228246364.tab") > > system("convert tmp/1cl4x1228246364.ps tmp/1cl4x1228246364.png") > > > proc.time() user system elapsed 1.179 0.279 1.228