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(154.783,187.646,237.863,215.54,231.745,199.548,164.147,159.388,203.514,224.901,211.539,211.16,181.712,203.908,240.774,232.819,255.221,246.7,206.263,211.679,236.601,237.43,233.767,219.52,222.625,216.238,248.587,221.376,242.453,246.539,189.351,185.956,213.175,228.732,212.93,218.254,227.103,219.026,264.529,262.057,258.779,231.928,211.167,205.439,224.883,228.624,209.435,215.607,287.356,306.015,338.546,344.16,328.412,342.006,277.668,290.477,314.967,324.627,290.646,315.033) > x <- c(299.63,305.945,382.252,348.846,335.367,373.617,312.612,312.232,337.161,331.476,350.103,345.127,297.256,295.979,361.007,321.803,354.937,349.432,290.979,349.576,327.625,349.377,336.777,339.134,323.321,318.86,373.583,333.03,408.556,414.646,291.514,348.857,349.368,375.765,364.136,349.53,348.167,332.856,360.551,346.969,392.815,372.02,371.027,342.672,367.343,390.786,343.785,362.6,349.468,340.624,369.536,407.782,392.239,404.824,373.669,344.902,396.7,398.911,366.009,392.484) > par7 = '0' > par6 = '0' > par5 = '1' > par4 = '1' > 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] 298.630 304.945 381.252 347.846 334.367 372.617 311.612 311.232 336.161 [10] 330.476 349.103 344.127 296.256 294.979 360.007 320.803 353.937 348.432 [19] 289.979 348.576 326.625 348.377 335.777 338.134 322.321 317.860 372.583 [28] 332.030 407.556 413.646 290.514 347.857 348.368 374.765 363.136 348.530 [37] 347.167 331.856 359.551 345.969 391.815 371.020 370.027 341.672 366.343 [46] 389.786 342.785 361.600 348.468 339.624 368.536 406.782 391.239 403.824 [55] 372.669 343.902 395.700 397.911 365.009 391.484 > y [1] 153.783 186.646 236.863 214.540 230.745 198.548 163.147 158.388 202.514 [10] 223.901 210.539 210.160 180.712 202.908 239.774 231.819 254.221 245.700 [19] 205.263 210.679 235.601 236.430 232.767 218.520 221.625 215.238 247.587 [28] 220.376 241.453 245.539 188.351 184.956 212.175 227.732 211.930 217.254 [37] 226.103 218.026 263.529 261.057 257.779 230.928 210.167 204.439 223.883 [46] 227.624 208.435 214.607 286.356 305.015 337.546 343.160 327.412 341.006 [55] 276.668 289.477 313.967 323.627 289.646 314.033 > postscript(file="/var/www/html/rcomp/tmp/1bnm41228071393.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.138 0.327 0.252 0.196 0.165 0.171 0.292 0.394 0.318 0.195 -3 -2 -1 0 1 2 3 4 5 6 7 0.199 0.167 0.335 0.659 0.479 0.358 0.363 0.243 0.296 0.393 0.292 8 9 10 11 12 13 14 0.164 0.067 -0.038 0.079 0.253 0.121 -0.002 > 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/2n1fc1228071394.tab") > > system("convert tmp/1bnm41228071393.ps tmp/1bnm41228071393.png") > > > proc.time() user system elapsed 0.400 0.184 0.462