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(13,8,7,3,3,4,4,0,-4,-14,-18,-8,-1,1,2,0,1,0,-1,-3,-3,-3,-4,-8,-9,-13,-18,-11,-9,-10,-13,-11,-5,-15,-6,-6,-3,-1,-3,-4,-6,0,-4,-2,-2,-6,-7,-6,-6,-3,-2,-5,-11,-11,-11,-10,-14,-8,-9,-5,-1) > x <- c(98.1,101.1,111.1,93.3,100,108,70.4,75.4,105.5,112.3,102.5,93.5,86.7,95.2,103.8,97,95.5,101,67.5,64,106.7,100.6,101.2,93.1,84.2,85.8,91.8,92.4,80.3,79.7,62.5,57.1,100.8,100.7,86.2,83.2,71.7,77.5,89.8,80.3,78.7,93.8,57.6,60.6,91,85.3,77.4,77.3,68.3,69.9,81.7,75.1,69.9,84,54.3,60,89.9,77,85.3,77.6,69.2) > par7 = '0' > par6 = '1' > par5 = '1' > par4 = '12' > par3 = '1' > par2 = '0' > par1 = '0.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] -0.194210118 -0.095117975 -0.108487569 0.061331079 -0.072806980 [6] -0.106667543 -0.064235026 -0.250510238 0.018031895 -0.175440174 [11] -0.020266720 -0.006747876 -0.045648408 -0.163109158 -0.194241883 [16] -0.076580091 -0.271132658 -0.371342137 -0.116823764 -0.171928842 [21] -0.090482131 0.001575679 -0.252534538 -0.175924339 -0.248355277 [26] -0.157992919 -0.034575442 -0.219158402 -0.031174687 0.254446414 [31] -0.122953401 0.089414039 -0.161403453 -0.261058010 -0.167248895 [36] -0.114029922 -0.074295704 -0.158643497 -0.147519920 -0.103457763 [41] -0.182401100 -0.172818806 -0.088227006 -0.014992316 -0.019082249 [46] -0.158870215 0.150868092 0.005984150 0.019984918 > y [1] -5 -1 -4 0 1 0 -4 -4 -10 -4 10 7 2 1 -2 1 -1 -1 -2 [20] 0 0 -1 -4 -1 -4 -5 7 2 -1 -3 2 6 -10 9 0 3 2 -2 [39] -1 -2 6 -4 2 0 -4 -1 1 0 3 1 -3 -6 0 0 1 -4 6 [58] -1 4 4 > postscript(file="/var/www/html/freestat/rcomp/tmp/15etz1228769501.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.112 -0.027 -0.023 -0.112 -0.034 0.090 0.169 -0.016 0.158 0.053 -0.271 -2 -1 0 1 2 3 4 5 6 7 8 0.250 0.012 0.152 0.077 -0.065 -0.048 -0.192 -0.055 -0.161 -0.249 0.139 9 10 11 12 13 0.127 0.118 0.073 -0.132 0.079 > 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/2iod21228769502.tab") > > system("convert tmp/15etz1228769501.ps tmp/15etz1228769501.png") > > > proc.time() user system elapsed 0.539 0.223 0.615