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(99.5,98.2,108.9,100.0,105.0,108.4,96.7,100.5,115.6,114.9,110.7,107.7,113.5,106.9,119.6,109.4,106.9,118.7,108.9,113.1,125.1,126.5,122.7,127.5,107.1,112.0,122.1,111.5,113.2,128.2,115.1,117.4,132.0,130.8,128.0,132.7,117.0,110.9,123.5,117.4,122.7,123.5,111.5,113.8,131.2,127.0,126.2,121.2,118.8,117.9,135.2,120.7,126.4,129.6,113.4,120.5,135.5,137.6,130.6,133.1,121.5,120.5,136.9,123.7,128.5,135.0,120.9,121.1,132.2,134.5,133.6,136.1,124.5,124.6,133.5,132.3,125.3,135.5,121.2,117.5,135.9) > x <- c(85.0,95.9,108.9,96.2,100.1,105.7,64.5,66.8,110.3,96.1,102.5,97.6,83.6,86.5,96.0,91.1,87.2,84.5,59.2,61.5,98.8,97.9,92.7,84.2,74.5,79.7,86.8,79.8,87.0,91.4,58.7,62.8,87.9,90.4,80.6,73.5,71.4,70.6,78.3,76.0,77.4,80.9,63.4,58.1,88.2,81.2,84.9,76.4,71.5,76.1,82.9,78.0,82.0,84.7,55.7,59.5,83.2,87.6,76.2,76.4,68.3,70.0,76.3,70.9,72.4,80.1,57.4,62.7,82.6,88.9,80.4,72.0,69.4,69.2,77.3,79.4,78.6,76.1,61.8,59.4,78.1) > par7 = '1' > par6 = '1' > par5 = '1' > par4 = '12' > par3 = '1' > 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] -1.4 -9.4 -12.9 -5.1 -12.9 -21.2 -5.3 -5.3 -11.5 1.8 -9.8 -13.4 [13] -9.1 -6.8 -9.2 -11.3 -0.2 6.9 -0.5 1.3 -10.9 -7.5 -12.1 -10.7 [25] -3.1 -9.1 -8.5 -3.8 -9.6 -10.5 4.7 -4.7 0.3 -9.2 4.3 2.9 [37] 0.1 5.5 4.6 2.0 4.6 3.8 -7.7 1.4 -5.0 6.4 -8.7 0.0 [49] -3.2 -6.1 -6.6 -7.1 -9.6 -4.6 1.7 3.2 -0.6 1.3 4.2 -4.4 [61] 1.1 -0.8 1.0 8.5 6.2 -4.0 4.4 -3.3 -4.5 > y [1] -5.300000e+00 2.000000e+00 -1.300000e+00 -7.500000e+00 8.400000e+00 [6] 1.900000e+00 4.000000e-01 -3.100000e+00 2.100000e+00 4.000000e-01 [11] 7.800000e+00 -2.620000e+01 1.150000e+01 -2.600000e+00 -4.000000e-01 [16] 4.200000e+00 3.200000e+00 -3.300000e+00 -1.900000e+00 2.600000e+00 [21] -2.600000e+00 1.000000e+00 -1.000000e-01 4.700000e+00 -1.100000e+01 [26] 2.500000e+00 4.500000e+00 3.600000e+00 -1.420000e+01 1.100000e+00 [31] -1.421085e-14 2.800000e+00 -3.000000e+00 2.000000e+00 -9.700000e+00 [36] 1.330000e+01 5.200000e+00 4.700000e+00 -8.400000e+00 4.000000e-01 [41] 2.400000e+00 -4.200000e+00 4.800000e+00 -2.400000e+00 6.300000e+00 [46] -6.200000e+00 7.500000e+00 -9.200000e+00 -1.000000e-01 -9.000000e-01 [51] 1.300000e+00 -9.000000e-01 3.300000e+00 2.100000e+00 -6.900000e+00 [56] -3.900000e+00 2.000000e-01 6.100000e+00 0.000000e+00 0.000000e+00 [61] 1.100000e+00 -7.500000e+00 1.200000e+01 -1.180000e+01 3.700000e+00 [66] -2.000000e-01 -3.900000e+00 7.300000e+00 > postscript(file="/var/www/html/rcomp/tmp/1gs3a1229592850.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 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -0.141 0.030 -0.032 0.107 -0.205 0.005 0.085 -0.071 -0.033 0.148 0.076 -4 -3 -2 -1 0 1 2 3 4 5 6 -0.076 0.126 -0.108 0.162 -0.129 0.152 0.026 0.013 0.134 0.165 -0.193 7 8 9 10 11 12 13 14 15 -0.091 0.002 0.031 -0.068 0.011 0.133 -0.107 0.085 0.001 > 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/2gcf81229592850.tab") > > system("convert tmp/1gs3a1229592850.ps tmp/1gs3a1229592850.png") > > > proc.time() user system elapsed 0.390 0.160 0.485