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(106.7,101.1,97.8,113.8,107.1,117.5,113.7,106.6,109.8,108.8,102.0,114.5,116.5,108.6,113.9,109.3,112.5,123.4,115.2,110.8,120.4,117.6,111.2,131.1,118.9,115.7,119.6,113.1,106.4,115.5,111.8,109.6,121.5,109.5,109.0,113.4,112.7,114.4,109.2,116.2,113.8,123.6,112.6,117.7,113.3,110.7,114.7,116.9,120.6,111.6,111.9,116.1,111.9,125.1,115.1,116.7,115.8,116.8,113.0,106.5) > x <- c(87.0,96.3,107.1,115.2,106.1,89.5,91.3,97.6,100.7,104.6,94.7,101.8,102.5,105.3,110.3,109.8,117.3,118.8,131.3,125.9,133.1,147.0,145.8,164.4,149.8,137.7,151.7,156.8,180.0,180.4,170.4,191.6,199.5,218.2,217.5,205.0,194.0,199.3,219.3,211.1,215.2,240.2,242.2,240.7,255.4,253.0,218.2,203.7,205.6,215.6,188.5,202.9,214.0,230.3,230.0,241.0,259.6,247.8,270.3,289.7) > 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] 86.0 95.3 106.1 114.2 105.1 88.5 90.3 96.6 99.7 103.6 93.7 100.8 [13] 101.5 104.3 109.3 108.8 116.3 117.8 130.3 124.9 132.1 146.0 144.8 163.4 [25] 148.8 136.7 150.7 155.8 179.0 179.4 169.4 190.6 198.5 217.2 216.5 204.0 [37] 193.0 198.3 218.3 210.1 214.2 239.2 241.2 239.7 254.4 252.0 217.2 202.7 [49] 204.6 214.6 187.5 201.9 213.0 229.3 229.0 240.0 258.6 246.8 269.3 288.7 > y [1] 105.7 100.1 96.8 112.8 106.1 116.5 112.7 105.6 108.8 107.8 101.0 113.5 [13] 115.5 107.6 112.9 108.3 111.5 122.4 114.2 109.8 119.4 116.6 110.2 130.1 [25] 117.9 114.7 118.6 112.1 105.4 114.5 110.8 108.6 120.5 108.5 108.0 112.4 [37] 111.7 113.4 108.2 115.2 112.8 122.6 111.6 116.7 112.3 109.7 113.7 115.9 [49] 119.6 110.6 110.9 115.1 110.9 124.1 114.1 115.7 114.8 115.8 112.0 105.5 > postscript(file="/var/www/html/rcomp/tmp/1rp7i1228215483.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 -0.080 -0.048 -0.052 -0.060 0.004 0.062 0.065 0.046 0.048 0.033 0.085 -3 -2 -1 0 1 2 3 4 5 6 7 0.107 0.182 0.211 0.250 0.298 0.312 0.327 0.312 0.321 0.324 0.221 8 9 10 11 12 13 14 0.271 0.263 0.277 0.296 0.280 0.222 0.208 > 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/2ivzc1228215483.tab") > > system("convert tmp/1rp7i1228215483.ps tmp/1rp7i1228215483.png") > > > proc.time() user system elapsed 0.388 0.169 0.471