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(93,98.4,92.6,94.6,99.5,97.6,91.3,93.6,93.1,78.4,70.2,69.3,71.1,73.5,85.9,91.5,91.8,88.3,91.3,94,99.3,96.7,88,96.7,106.8,114.3,105.7,90.1,91.6,97.7,100.8,104.6,95.9,102.7,104,107.9,113.8,113.8,123.1,125.1,137.6,134,140.3,152.1,150.6,167.3,153.2,142,154.4,158.5,180.9,181.3,172.4,192,199.3,215.4,214.3,201.5,190.5,196) > x <- c(99.4,97.5,94.6,92.6,92.5,89.8,88.8,87.4,85.2,83.1,84.7,84.8,85.8,86.3,89,89,89.3,91.9,94.9,94.4,96.8,96.9,98,97.9,100.9,103.9,103.1,102.5,104.3,102.6,101.7,102.8,105.4,110.9,113.5,116.3,124,128.8,133.5,132.6,128.4,127.3,126.7,123.3,123.2,124.4,128.2,128.7,135.7,139,145.4,142.4,137.7,137,137.1,139.3,139.6,140.4,142.3,148.3) > 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] 98.4 96.5 93.6 91.6 91.5 88.8 87.8 86.4 84.2 82.1 83.7 83.8 [13] 84.8 85.3 88.0 88.0 88.3 90.9 93.9 93.4 95.8 95.9 97.0 96.9 [25] 99.9 102.9 102.1 101.5 103.3 101.6 100.7 101.8 104.4 109.9 112.5 115.3 [37] 123.0 127.8 132.5 131.6 127.4 126.3 125.7 122.3 122.2 123.4 127.2 127.7 [49] 134.7 138.0 144.4 141.4 136.7 136.0 136.1 138.3 138.6 139.4 141.3 147.3 > y [1] 92.0 97.4 91.6 93.6 98.5 96.6 90.3 92.6 92.1 77.4 69.2 68.3 [13] 70.1 72.5 84.9 90.5 90.8 87.3 90.3 93.0 98.3 95.7 87.0 95.7 [25] 105.8 113.3 104.7 89.1 90.6 96.7 99.8 103.6 94.9 101.7 103.0 106.9 [37] 112.8 112.8 122.1 124.1 136.6 133.0 139.3 151.1 149.6 166.3 152.2 141.0 [49] 153.4 157.5 179.9 180.3 171.4 191.0 198.3 214.4 213.3 200.5 189.5 195.0 > postscript(file="/var/www/html/rcomp/tmp/1ayml1228241386.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.435 0.467 0.501 0.543 0.591 0.651 0.704 0.750 0.789 0.818 0.841 0.857 0.872 -1 0 1 2 3 4 5 6 7 8 9 10 11 0.887 0.908 0.857 0.811 0.757 0.690 0.621 0.556 0.493 0.444 0.384 0.323 0.276 12 13 14 0.232 0.197 0.150 > 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/22rf21228241387.tab") > > system("convert tmp/1ayml1228241386.ps tmp/1ayml1228241386.png") > > > proc.time() user system elapsed 0.377 0.167 0.444