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(123.28,133.52,153.20,163.63,168.45,166.26,162.31,161.56,156.59,157.97,158.68,163.55,162.89,164.95,159.82,159.05,166.76,164.55,163.22,160.68,155.24,157.60,156.56,154.82,151.11,149.65,148.99,148.53,146.70,145.11,142.70,143.59,140.96,140.77,139.81,140.58,139.59,138.05,136.06,135.98,134.75,132.22,135.37,138.84,138.83,136.55,135.63,139.14,136.09,135.97,134.51,134.54,134.08,132.86,134.48,129.08,133.13,134.78,134.13,132.43,127.84,128.12,128.94,132.38,134.99,138.05,135.83,130.12,128.16,128.60,126.12,124.20,121.65,121.57,118.38,116.31,117.11,117.80,115.86,115.81,114.75,116.23,117.12,113.38,108.68,109.86,108.20,109.34,107.21,104.30,106.50,110.36,110.33,107.08,109.57,100.61,93.26,92.74,93.11,97.76,101.39,100.71,98.09,99.92,102.59,107.64,106.53,103.72,108.25,113.52,112.39,120.10,123.71,125.32,129.71,128.16,130.20,130.78,131.35) > x <- c(1.2732,1.3322,1.4369,1.4975,1.5770,1.5553,1.5557,1.5750,1.5527,1.4748,1.4718,1.4570,1.4684,1.4227,1.3896,1.3622,1.3716,1.3419,1.3511,1.3516,1.3242,1.3074,1.2999,1.3213,1.2881,1.2611,1.2727,1.2811,1.2684,1.2650,1.2770,1.2271,1.2020,1.1938,1.2103,1.1856,1.1786,1.2015,1.2256,1.2292,1.2037,1.2165,1.2694,1.2938,1.3201,1.3014,1.3119,1.3408,1.2991,1.2490,1.2218,1.2176,1.2266,1.2138,1.2007,1.1985,1.2262,1.2646,1.2613,1.2286,1.1702,1.1692,1.1222,1.1139,1.1372,1.1663,1.1582,1.0848,1.0807,1.0773,1.0622,1.0183,1.0014,0.9811,0.9808,0.9778,0.9922,0.9554,0.9170,0.8858,0.8758,0.8700,0.8833,0.8924,0.8883,0.9059,0.9111,0.9005,0.8607,0.8532,0.8742,0.8920,0.9095,0.9217,0.9383,0.8973,0.8564,0.8552,0.8721,0.9041,0.9397,0.9492,0.9060,0.9470,0.9643,0.9834,1.0137,1.0110,1.0338,1.0706,1.0501,1.0604,1.0353,1.0378,1.0628,1.0704,1.0883,1.1208,1.1608) > 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] 0.2732 0.3322 0.4369 0.4975 0.5770 0.5553 0.5557 0.5750 0.5527 [10] 0.4748 0.4718 0.4570 0.4684 0.4227 0.3896 0.3622 0.3716 0.3419 [19] 0.3511 0.3516 0.3242 0.3074 0.2999 0.3213 0.2881 0.2611 0.2727 [28] 0.2811 0.2684 0.2650 0.2770 0.2271 0.2020 0.1938 0.2103 0.1856 [37] 0.1786 0.2015 0.2256 0.2292 0.2037 0.2165 0.2694 0.2938 0.3201 [46] 0.3014 0.3119 0.3408 0.2991 0.2490 0.2218 0.2176 0.2266 0.2138 [55] 0.2007 0.1985 0.2262 0.2646 0.2613 0.2286 0.1702 0.1692 0.1222 [64] 0.1139 0.1372 0.1663 0.1582 0.0848 0.0807 0.0773 0.0622 0.0183 [73] 0.0014 -0.0189 -0.0192 -0.0222 -0.0078 -0.0446 -0.0830 -0.1142 -0.1242 [82] -0.1300 -0.1167 -0.1076 -0.1117 -0.0941 -0.0889 -0.0995 -0.1393 -0.1468 [91] -0.1258 -0.1080 -0.0905 -0.0783 -0.0617 -0.1027 -0.1436 -0.1448 -0.1279 [100] -0.0959 -0.0603 -0.0508 -0.0940 -0.0530 -0.0357 -0.0166 0.0137 0.0110 [109] 0.0338 0.0706 0.0501 0.0604 0.0353 0.0378 0.0628 0.0704 0.0883 [118] 0.1208 0.1608 > y [1] 122.28 132.52 152.20 162.63 167.45 165.26 161.31 160.56 155.59 156.97 [11] 157.68 162.55 161.89 163.95 158.82 158.05 165.76 163.55 162.22 159.68 [21] 154.24 156.60 155.56 153.82 150.11 148.65 147.99 147.53 145.70 144.11 [31] 141.70 142.59 139.96 139.77 138.81 139.58 138.59 137.05 135.06 134.98 [41] 133.75 131.22 134.37 137.84 137.83 135.55 134.63 138.14 135.09 134.97 [51] 133.51 133.54 133.08 131.86 133.48 128.08 132.13 133.78 133.13 131.43 [61] 126.84 127.12 127.94 131.38 133.99 137.05 134.83 129.12 127.16 127.60 [71] 125.12 123.20 120.65 120.57 117.38 115.31 116.11 116.80 114.86 114.81 [81] 113.75 115.23 116.12 112.38 107.68 108.86 107.20 108.34 106.21 103.30 [91] 105.50 109.36 109.33 106.08 108.57 99.61 92.26 91.74 92.11 96.76 [101] 100.39 99.71 97.09 98.92 101.59 106.64 105.53 102.72 107.25 112.52 [111] 111.39 119.10 122.71 124.32 128.71 127.16 129.20 129.78 130.35 > postscript(file="/var/www/html/rcomp/tmp/17d1t1228229940.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 -6 -5 0.619 0.652 0.685 0.716 0.746 0.775 0.802 0.827 0.850 0.868 0.883 0.896 0.908 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 0.915 0.923 0.931 0.935 0.928 0.905 0.874 0.840 0.805 0.771 0.735 0.701 0.669 9 10 11 12 13 14 15 16 17 0.638 0.605 0.574 0.545 0.516 0.489 0.462 0.437 0.413 > 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/2kt9w1228229940.tab") > > system("convert tmp/17d1t1228229940.ps tmp/17d1t1228229940.png") > > > proc.time() user system elapsed 0.410 0.186 0.493