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(2341,2540,2371,2122,2301,2512,3145,2741,2548,1987,2281,2016,2434,2637,1831,1851,1839,2609,2417,2394,2372,2717,2998,2538,3007,2475,2175,2465,2279,2323,2746,2601,2486,2718,2646,2551,2712,2606,2365,3533,3509,2912,3599,2719,2869,4085,2686,2545,3071,3388,2652,3190,2884,3295,3818,3226,3953,3810,2877,3515,3708,3450,3360,4110,4384,3729,4263,3505,3674,3911,2951,3317,3417,3498,2768,2899,3171,3004,3481,3016,2595,3509,2833,3125,2556,3628,2876,2575,2903,3438,2926,3068,3015) > x <- c(3353,3480,3098,2944,3389,3497,4404,3849,3734,3060,3507,3287,3215,3764,2734,2837,2766,3851,3289,3848,3348,3682,4058,3655,3811,3341,3032,3475,3353,3186,3902,4164,3499,4145,3796,3711,3949,3740,3243,4407,4814,3908,5250,3937,4004,5560,3922,3759,4138,4634,3996,4308,4142,4429,5219,4929,5754,5592,4163,4962,5208,4755,4491,5732,5730,5024,6056,4901,5353,5578,4618,4724,5011,5298,4143,4617,4727,4207,5112,4190,4098,5071,4177,4598,3757,5591,4218,3780,4336,4870,4422,4727,4459) > par7 = '0' > par6 = '1' > par5 = '1' > par4 = '12' > par3 = '0' > par2 = '1' > 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] 127 -382 -154 445 108 907 -555 -115 -674 447 -220 -72 [13] 549 -1030 103 -71 1085 -562 559 -500 334 376 -403 156 [25] -470 -309 443 -122 -167 716 262 -665 646 -349 -85 238 [37] -209 -497 1164 407 -906 1342 -1313 67 1556 -1638 -163 379 [49] 496 -638 312 -166 287 790 -290 825 -162 -1429 799 246 [61] -453 -264 1241 -2 -706 1032 -1155 452 225 -960 106 287 [73] 287 -1155 474 110 -520 905 -922 -92 973 -894 421 -841 [85] 1834 -1373 -438 556 534 -448 305 -268 > y [1] 199 -169 -249 179 211 633 -404 -193 -561 294 -265 418 [13] 203 -806 20 -12 770 -192 -23 -22 345 281 -460 469 [25] -532 -300 290 -186 44 423 -145 -115 232 -72 -95 161 [37] -106 -241 1168 -24 -597 687 -880 150 1216 -1399 -141 526 [49] 317 -736 538 -306 411 523 -592 727 -143 -933 638 193 [61] -258 -90 750 274 -655 534 -758 169 237 -960 366 100 [73] 81 -730 131 272 -167 477 -465 -421 914 -676 292 -569 [85] 1072 -752 -301 328 535 -512 142 -53 > postscript(file="/var/www/html/rcomp/tmp/17le51227727281.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 -16 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -0.181 0.133 0.024 -0.246 0.323 -0.113 -0.146 0.241 -0.114 -0.048 0.065 -5 -4 -3 -2 -1 0 1 2 3 4 5 0.007 -0.147 0.250 -0.147 -0.452 0.931 -0.412 -0.116 0.179 -0.054 -0.069 6 7 8 9 10 11 12 13 14 15 16 0.088 0.037 -0.246 0.241 -0.043 -0.209 0.379 -0.235 -0.051 0.184 -0.136 > 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/2iznu1227727282.tab") > > system("convert tmp/17le51227727281.ps tmp/17le51227727281.png") > > > proc.time() user system elapsed 0.390 0.171 0.464