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(107.1,110.7,117.1,118.7,126.5,127.5,134.6,131.8,135.9,142.7,141.7,153.4,145.0,137.7,148.3,152.2,169.4,168.6,161.1,174.1,179.0,190.6,190.0,181.6,174.8,180.5,196.8,193.8,197.0,216.3,221.4,217.9,229.7,227.4,204.2,196.6,198.8,207.5,190.7,201.6,210.5,223.5,223.8,231.2,244.0,234.7,250.2,265.7,287.6,283.3,295.4,312.3,333.8,347.7,383.2,407.1,413.6,362.7,321.9,239.4) > x <- c(118.4,121.4,128.8,131.7,141.7,142.9,139.4,134.7,125.0,113.6,111.5,108.5,112.3,116.6,115.5,120.1,132.9,128.1,129.3,132.5,131.0,124.9,120.8,122.0,122.1,127.4,135.2,137.3,135.0,136.0,138.4,134.7,138.4,133.9,133.6,141.2,151.8,155.4,156.6,161.6,160.7,156.0,159.5,168.7,169.9,169.9,185.9,190.8,195.8,211.9,227.1,251.3,256.7,251.9,251.2,270.3,267.2,243.0,229.9,187.2) > 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] 117.4 120.4 127.8 130.7 140.7 141.9 138.4 133.7 124.0 112.6 110.5 107.5 [13] 111.3 115.6 114.5 119.1 131.9 127.1 128.3 131.5 130.0 123.9 119.8 121.0 [25] 121.1 126.4 134.2 136.3 134.0 135.0 137.4 133.7 137.4 132.9 132.6 140.2 [37] 150.8 154.4 155.6 160.6 159.7 155.0 158.5 167.7 168.9 168.9 184.9 189.8 [49] 194.8 210.9 226.1 250.3 255.7 250.9 250.2 269.3 266.2 242.0 228.9 186.2 > y [1] 106.1 109.7 116.1 117.7 125.5 126.5 133.6 130.8 134.9 141.7 140.7 152.4 [13] 144.0 136.7 147.3 151.2 168.4 167.6 160.1 173.1 178.0 189.6 189.0 180.6 [25] 173.8 179.5 195.8 192.8 196.0 215.3 220.4 216.9 228.7 226.4 203.2 195.6 [37] 197.8 206.5 189.7 200.6 209.5 222.5 222.8 230.2 243.0 233.7 249.2 264.7 [49] 286.6 282.3 294.4 311.3 332.8 346.7 382.2 406.1 412.6 361.7 320.9 238.4 > postscript(file="/var/www/html/rcomp/tmp/15ta51228240676.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.070 0.103 0.140 0.178 0.225 0.280 0.348 0.432 0.523 0.615 0.699 0.778 0.845 -1 0 1 2 3 4 5 6 7 8 9 10 11 0.900 0.928 0.897 0.839 0.769 0.692 0.627 0.573 0.528 0.482 0.437 0.389 0.340 12 13 14 0.292 0.255 0.229 > 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/2ll6y1228240676.tab") > > system("convert tmp/15ta51228240676.ps tmp/15ta51228240676.png") > > > proc.time() user system elapsed 0.393 0.164 0.610