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(104.3,119.8,116.8,118.2,107.4,110.8,94.8,96.5,113.4,109.8,118.7,117.2,110.3,111.6,128.1,121.3,107.3,120.5,98.5,97.7,113.2,114.6,118.3,123.9,113.6,117.5,130.1,124.7,114.2,127.3,105.9,101.5,120.2,117.1,131.1,130,120.6,123.1,135.3,134.1,123.7,134.6,108.3,110.4,127.8,126.6,131.4,141.1,127,127.3,143.6,149.4,126.6,136.5,116,118,131.4,140.7,144.9,143.9,127.1) > x <- c(569,580,578,565,547,555,562,561,555,544,537,543,594,611,613,611,594,595,591,589,584,573,567,569,621,629,628,612,595,597,593,590,580,574,573,573,620,626,620,588,566,557,561,549,532,526,511,499,555,565,542,527,510,514,517,508,493,490,469,478,528) > par7 = '1' > par6 = '0' > par5 = '1' > par4 = '12' > par3 = '1' > par2 = '1' > 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] 6 4 11 1 -7 -11 -1 1 0 1 -4 1 -9 -3 -14 0 1 0 -1 [20] -5 5 5 -2 -5 -2 -5 -16 -5 -11 8 -9 -7 0 -14 -12 9 4 -17 [39] 17 5 13 -1 3 2 3 -6 21 -6 > y [1] 6.0 -8.2 11.3 3.1 -0.1 9.7 3.7 1.2 -0.2 4.8 -0.4 6.7 3.3 5.9 2.0 [16] 3.4 6.9 6.8 7.4 3.8 7.0 2.5 12.8 6.1 7.0 5.6 5.2 9.4 9.5 7.3 [31] 2.4 8.9 7.6 9.5 0.3 11.1 6.4 4.2 8.3 15.3 2.9 1.9 7.7 7.6 3.6 [46] 14.1 13.5 2.8 0.1 > postscript(file="/var/www/html/rcomp/tmp/1f2y71228229741.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 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -0.158 -0.257 -0.003 0.082 -0.180 -0.140 0.160 -0.042 -0.161 0.111 0.091 -2 -1 0 1 2 3 4 5 6 7 8 -0.104 -0.146 0.202 0.013 -0.113 0.126 0.112 0.013 -0.167 0.313 -0.056 9 10 11 12 13 -0.001 -0.065 0.237 -0.081 0.247 > 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/2mdo61228229741.tab") > > system("convert tmp/1f2y71228229741.ps tmp/1f2y71228229741.png") > > > proc.time() user system elapsed 0.392 0.181 0.458