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(2187,1852,1570,1851,1954,1828,2251,2277,2085,2282,2266,1878,2267,2069,1746,2299,2360,2214,2825,2355,2333,3016,2155,2172,2150,2533,2058,2160,2259,2498,2695,2799,2945,2930,2318,2540,2570,2669,2450,2842,3439,2677,2979,2257,2842,2546,2455,2293,2379,2478,2054,2272,2351,2271,2542,2304,2194,2722,2395,2146,1894,2548,2087,2063,2481,2476,2212,2834,2148,2598) > x <- c(109.1,113.8,97.4,72.5,82.7,88.9,105.9,100.8,94,105,58.5,87.6,113.1,112.5,89.6,74.5,82.7,90.1,109.4,96,89.2,109.1,49.1,92.9,107.7,103.5,91.1,79.8,71.9,82.9,90.1,100.7,90.7,108.8,44.1,93.6,107.4,96.5,93.6,76.5,76.7,84,103.3,88.5,99,105.9,44.7,94,107.1,104.8,102.5,77.7,85.2,91.3,106.5,92.4,97.5,107,51.1,98.6,102.2,114.3,99.4,72.5,92.3,99.4,85.9,109.4,97.6,104.7) > 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] 108.1 112.8 96.4 71.5 81.7 87.9 104.9 99.8 93.0 104.0 57.5 86.6 [13] 112.1 111.5 88.6 73.5 81.7 89.1 108.4 95.0 88.2 108.1 48.1 91.9 [25] 106.7 102.5 90.1 78.8 70.9 81.9 89.1 99.7 89.7 107.8 43.1 92.6 [37] 106.4 95.5 92.6 75.5 75.7 83.0 102.3 87.5 98.0 104.9 43.7 93.0 [49] 106.1 103.8 101.5 76.7 84.2 90.3 105.5 91.4 96.5 106.0 50.1 97.6 [61] 101.2 113.3 98.4 71.5 91.3 98.4 84.9 108.4 96.6 103.7 > y [1] 2186 1851 1569 1850 1953 1827 2250 2276 2084 2281 2265 1877 2266 2068 1745 [16] 2298 2359 2213 2824 2354 2332 3015 2154 2171 2149 2532 2057 2159 2258 2497 [31] 2694 2798 2944 2929 2317 2539 2569 2668 2449 2841 3438 2676 2978 2256 2841 [46] 2545 2454 2292 2378 2477 2053 2271 2350 2270 2541 2303 2193 2721 2394 2145 [61] 1893 2547 2086 2062 2480 2475 2211 2833 2147 2597 > postscript(file="/var/www/html/rcomp/tmp/1ltk31228745839.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 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -0.107 -0.069 -0.033 0.023 -0.185 -0.105 0.041 -0.061 0.023 -0.166 -0.113 -4 -3 -2 -1 0 1 2 3 4 5 6 0.053 -0.193 -0.127 -0.153 0.116 -0.190 -0.048 0.113 -0.145 0.021 -0.098 7 8 9 10 11 12 13 14 15 -0.138 0.140 -0.091 -0.060 -0.044 0.115 -0.043 0.004 0.133 > 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/24lzr1228745839.tab") > > system("convert tmp/1ltk31228745839.ps tmp/1ltk31228745839.png") > > > proc.time() user system elapsed 0.389 0.171 0.444