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(116.5,118.2,118.8,116.4,118.6,131.4,119.4,119.3,119.1,119.4,120.4,120.3,118.3,118.9,119.9,119.2,118.6,117.5,118.2,120.4,118.0,119.6,120.1,118.5,112.0,112.9,111.1,114.8,113.8,110.8,113.3,115.3,115.1,115.4,113.2,119.4,119.3,115.8,112.8,115.2) > x <- c(132.7,128.6,127.8,128.9,124.6,129.2,130.5,124.3,125.8,123.5,120.7,123.1,122.0,121.0,121.2,117.4,113.0,113.1,116.1,121.3,108.6,114.3,113.5,111.2,109.3,108.2,102.7,110.4,108.1,112.8,108.1,102.6,109.2,108.2,107.1,108.4,103.6,104.0,111.5,105.4) > par7 = '0' > par6 = '0' > par5 = '1' > par4 = '12' > par3 = '0' > 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] -4.1 -0.8 1.1 -4.3 4.6 1.3 -6.2 1.5 -2.3 -2.8 2.4 -1.1 [13] -1.0 0.2 -3.8 -4.4 0.1 3.0 5.2 -12.7 5.7 -0.8 -2.3 -1.9 [25] -1.1 -5.5 7.7 -2.3 4.7 -4.7 -5.5 6.6 -1.0 -1.1 1.3 -4.8 [37] 0.4 7.5 -6.1 > y [1] 115.5 117.2 117.8 115.4 117.6 130.4 118.4 118.3 118.1 118.4 119.4 119.3 [13] 117.3 117.9 118.9 118.2 117.6 116.5 117.2 119.4 117.0 118.6 119.1 117.5 [25] 111.0 111.9 110.1 113.8 112.8 109.8 112.3 114.3 114.1 114.4 112.2 118.4 [37] 118.3 114.8 111.8 114.2 > postscript(file="/var/www/html/freestat/rcomp/tmp/143211228233407.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 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 -0.059 0.005 0.054 0.060 -0.090 -0.023 -0.092 0.039 -0.006 -0.012 -0.086 -1 0 1 2 3 4 5 6 7 8 9 0.057 -0.038 -0.074 -0.101 -0.099 -0.063 0.043 0.018 -0.067 -0.083 -0.019 10 11 12 -0.078 -0.027 0.117 > 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/2rkes1228233407.tab") > > system("convert tmp/143211228233407.ps tmp/143211228233407.png") > > > proc.time() user system elapsed 0.546 0.215 0.620