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(1721,1476,1842,2171,1670,1540,1266,897,1266,1519,1074,1435,1385,1440,1883,1822,1661,1774,1133,1361,1688,2216,2896,1382,1330,1419,1662,2040,2126,1649,1610,1952,2102,1749,2091,3036,2414,2097,2705,2431,4192,3990,2854,1966,2431,2763,2831,2023,2934,2489,3252,3018,3193,3976,2584,2512,2169,2504,1843,1408,2179,3690,2372,2494,3872,2786,2312,1599,3167,3433,2648,1978,1947,3113,2856,3174,3507,4174,2978,4428,2832,2930,3681,3253,1660,2208,3139,3409,3445,2410,3262,2897,2526,3982,4097,3403,3362,2708,3129,3550,2696,2885,2945,3600,3808,3671,4005) > x <- c(0.44,0.09,0.2,0.82,0.5,0.2,1,0.47,0.49,0.82,0.39,0.6,0.59,0.72,0.97,0.58,0.27,0.84,0.51,0.13,0.65,0.51,1.06,0.81,0.54,0.85,0.93,0.29,1.01,0.65,0.88,0.45,0.74,1.08,0.27,0.24,0.27,0.25,0.69,0.73,1.04,1.04,0.3,0.59,0.72,0.22,1.12,0.93,0.99,0.56,1,0.57,1,0.97,0.3,0.45,0.73,1.13,0.65,0.64,0.68,0.41,0.98,0.3,0.37,1.12,0.4,0.5,1.23,0.94,1.08,1.12,0.83,1.22,0.55,0.38,1.26,0.49,1.13,1.07,0.86,0.94,0.45,0.66,0.71,0.54,0.9,1.23,0.46,1.33,0.64,0.9,0.5,1.37,0.96,0.62,1.24,1.1,0.86,1.2,0.77,0.67,1.05,1.32,0.6,1.31,1.41) > par7 = '0' > par6 = '1' > par5 = '0.0' > par4 = '12' > par3 = '0' > par2 = '1' > par1 = '1.0' > #'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.35 0.11 0.62 -0.32 -0.30 0.80 -0.53 0.02 0.33 -0.43 0.21 -0.01 [13] 0.13 0.25 -0.39 -0.31 0.57 -0.33 -0.38 0.52 -0.14 0.55 -0.25 -0.27 [25] 0.31 0.08 -0.64 0.72 -0.36 0.23 -0.43 0.29 0.34 -0.81 -0.03 0.03 [37] -0.02 0.44 0.04 0.31 0.00 -0.74 0.29 0.13 -0.50 0.90 -0.19 0.06 [49] -0.43 0.44 -0.43 0.43 -0.03 -0.67 0.15 0.28 0.40 -0.48 -0.01 0.04 [61] -0.27 0.57 -0.68 0.07 0.75 -0.72 0.10 0.73 -0.29 0.14 0.04 -0.29 [73] 0.39 -0.67 -0.17 0.88 -0.77 0.64 -0.06 -0.21 0.08 -0.49 0.21 0.05 [85] -0.17 0.36 0.33 -0.77 0.87 -0.69 0.26 -0.40 0.87 -0.41 -0.34 0.62 [97] -0.14 -0.24 0.34 -0.43 -0.10 0.38 0.27 -0.72 0.71 0.10 > y [1] -0.15356979 0.22151621 0.16433595 -0.26236426 -0.08104121 -0.19592009 [7] -0.34456174 0.34456174 0.18218990 -0.34666223 0.28977485 -0.03546471 [13] 0.03894297 0.26822314 -0.03293145 -0.09251497 0.06581705 -0.44836790 [19] 0.18335074 0.21532467 0.27215937 0.26762671 -0.73979875 -0.03835278 [25] 0.06477346 0.15806930 0.20492811 0.04129247 -0.25407324 -0.02393486 [31] 0.19262031 0.07403478 -0.18384508 0.17859822 0.37289844 -0.22925574 [37] -0.14077737 0.25459416 -0.10679922 0.54487525 -0.04938672 -0.33506971 [43] -0.37272050 0.21230167 0.12801435 0.02431296 -0.33604845 0.37178512 [49] -0.16448566 0.26738917 -0.07467583 0.05636655 0.21931538 -0.43093770 [55] -0.02825934 -0.14681302 0.14362322 -0.30649477 -0.26922442 0.43669580 [61] 0.52676040 -0.44189298 0.05015437 0.43988332 -0.32916429 -0.18649392 [67] -0.36873452 0.68340633 0.08064975 -0.25962988 -0.29171840 -0.01579651 [73] 0.46929717 -0.08616485 0.10557058 0.09976835 0.17411384 -0.33762287 [79] 0.39669608 -0.44696484 0.03401925 0.22818203 -0.12360681 -0.67276005 [85] 0.28526953 0.35181715 0.08251472 0.01050491 -0.35729716 0.30271376 [91] -0.11866479 -0.13703869 0.45514718 0.02847079 -0.18559760 -0.01212136 [97] -0.21632568 0.14450311 0.12623414 -0.27517841 0.06775571 0.02058392 [103] 0.20082503 0.05617027 -0.03664001 0.08707948 > postscript(file="/var/www/html/freestat/rcomp/tmp/1x3361229549709.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 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 0.098 -0.134 0.007 0.037 -0.055 0.079 -0.030 -0.053 0.030 0.021 0.047 -6 -5 -4 -3 -2 -1 0 1 2 3 4 -0.069 0.054 -0.024 -0.020 -0.007 -0.094 0.168 0.030 -0.144 0.017 0.098 5 6 7 8 9 10 11 12 13 14 15 -0.103 0.050 -0.044 0.115 -0.087 -0.054 0.016 0.224 -0.183 -0.037 -0.009 16 17 -0.007 0.090 > 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/2trav1229549709.tab") > > system("convert tmp/1x3361229549709.ps tmp/1x3361229549709.png") > > > proc.time() user system elapsed 0.553 0.221 0.602