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(2400,4700,3700,2900,2800,3000,3100,3700,3000,2000,1900,1900,1800,3400,3800,2800,3100,2100,2000,2500,2400,2500,3300,3100,3700,5600,3700,2900,4000,2900,2400,3300,3800,4400,4000,3100,2700,5200,4600,3700,3200,2400,2200,3200,3100,2300,2500,2900,2700,5000,3500,3000,3800,2800,2400,2700,2800,2700,2600,3100) > x <- c(5014,6153,6441,5584,6427,6062,5589,6216,5809,4989,6706,7174,6122,8075,6292,6337,8576,6077,5931,6288,7167,6054,6468,6401,6927,7914,7728,8699,8522,6481,7502,7778,7424,6941,8574,9169,7701,9035,7158,8195,8124,7073,7017,7390,7776,6197,6889,7087,6485,7654,6501,6313,7826,6589,6729,5684,8105,6391,5901,6758) > 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] 5013 6152 6440 5583 6426 6061 5588 6215 5808 4988 6705 7173 6121 8074 6291 [16] 6336 8575 6076 5930 6287 7166 6053 6467 6400 6926 7913 7727 8698 8521 6480 [31] 7501 7777 7423 6940 8573 9168 7700 9034 7157 8194 8123 7072 7016 7389 7775 [46] 6196 6888 7086 6484 7653 6500 6312 7825 6588 6728 5683 8104 6390 5900 6757 > y [1] 2399 4699 3699 2899 2799 2999 3099 3699 2999 1999 1899 1899 1799 3399 3799 [16] 2799 3099 2099 1999 2499 2399 2499 3299 3099 3699 5599 3699 2899 3999 2899 [31] 2399 3299 3799 4399 3999 3099 2699 5199 4599 3699 3199 2399 2199 3199 3099 [46] 2299 2499 2899 2699 4999 3499 2999 3799 2799 2399 2699 2799 2699 2599 3099 > postscript(file="/var/www/html/rcomp/tmp/1mwxu1229943830.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.062 0.046 0.358 0.079 0.165 0.319 0.059 0.008 0.150 0.060 0.033 -3 -2 -1 0 1 2 3 4 5 6 7 0.314 0.121 0.121 0.430 0.156 0.287 0.351 0.048 0.036 0.133 0.015 8 9 10 11 12 13 14 -0.115 0.164 0.092 0.083 0.238 -0.021 -0.006 > 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/2tdxe1229943830.tab") > > system("convert tmp/1mwxu1229943830.ps tmp/1mwxu1229943830.png") > > > proc.time() user system elapsed 0.393 0.162 0.470