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 = '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.56 -0.91 -0.80 -0.18 -0.50 -0.80 0.00 -0.53 -0.51 -0.18 -0.61 -0.40 [13] -0.41 -0.28 -0.03 -0.42 -0.73 -0.16 -0.49 -0.87 -0.35 -0.49 0.06 -0.19 [25] -0.46 -0.15 -0.07 -0.71 0.01 -0.35 -0.12 -0.55 -0.26 0.08 -0.73 -0.76 [37] -0.73 -0.75 -0.31 -0.27 0.04 0.04 -0.70 -0.41 -0.28 -0.78 0.12 -0.07 [49] -0.01 -0.44 0.00 -0.43 0.00 -0.03 -0.70 -0.55 -0.27 0.13 -0.35 -0.36 [61] -0.32 -0.59 -0.02 -0.70 -0.63 0.12 -0.60 -0.50 0.23 -0.06 0.08 0.12 [73] -0.17 0.22 -0.45 -0.62 0.26 -0.51 0.13 0.07 -0.14 -0.06 -0.55 -0.34 [85] -0.29 -0.46 -0.10 0.23 -0.54 0.33 -0.36 -0.10 -0.50 0.37 -0.04 -0.38 [97] 0.24 0.10 -0.14 0.20 -0.23 -0.33 0.05 0.32 -0.40 0.31 0.41 > y [1] 1720 1475 1841 2170 1669 1539 1265 896 1265 1518 1073 1434 1384 1439 1882 [16] 1821 1660 1773 1132 1360 1687 2215 2895 1381 1329 1418 1661 2039 2125 1648 [31] 1609 1951 2101 1748 2090 3035 2413 2096 2704 2430 4191 3989 2853 1965 2430 [46] 2762 2830 2022 2933 2488 3251 3017 3192 3975 2583 2511 2168 2503 1842 1407 [61] 2178 3689 2371 2493 3871 2785 2311 1598 3166 3432 2647 1977 1946 3112 2855 [76] 3173 3506 4173 2977 4427 2831 2929 3680 3252 1659 2207 3138 3408 3444 2409 [91] 3261 2896 2525 3981 4096 3402 3361 2707 3128 3549 2695 2884 2944 3599 3807 [106] 3670 4004 > postscript(file="/var/www/html/freestat/rcomp/tmp/1g3ol1229549504.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.180 0.041 0.117 0.116 0.124 0.214 0.154 0.172 0.244 0.258 0.305 0.225 0.217 -4 -3 -2 -1 0 1 2 3 4 5 6 7 8 0.219 0.219 0.204 0.288 0.393 0.305 0.185 0.223 0.268 0.184 0.226 0.259 0.248 9 10 11 12 13 14 15 16 17 0.174 0.213 0.220 0.306 0.054 0.063 0.151 0.184 0.239 > 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/2rbua1229549504.tab") > > system("convert tmp/1g3ol1229549504.ps tmp/1g3ol1229549504.png") > > > proc.time() user system elapsed 0.552 0.222 0.611