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 = '0' > par5 = '1' > par4 = '12' > par3 = '0' > par2 = '0' > par1 = '-2.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.5000000 0.5000000 0.4999999 0.4999999 0.5000000 0.5000000 0.5000000 [8] 0.5000000 0.5000000 0.4999999 0.5000000 0.5000000 0.5000000 0.5000000 [15] 0.4999999 0.4999999 0.4999999 0.5000000 0.5000000 0.5000000 0.5000000 [22] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.4999999 0.5000000 [29] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [36] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [43] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [50] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [57] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [64] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [71] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [78] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [85] 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 0.5000000 [92] 0.5000000 0.5000000 > y [1] 2340 2539 2370 2121 2300 2511 3144 2740 2547 1986 2280 2015 2433 2636 1830 [16] 1850 1838 2608 2416 2393 2371 2716 2997 2537 3006 2474 2174 2464 2278 2322 [31] 2745 2600 2485 2717 2645 2550 2711 2605 2364 3532 3508 2911 3598 2718 2868 [46] 4084 2685 2544 3070 3387 2651 3189 2883 3294 3817 3225 3952 3809 2876 3514 [61] 3707 3449 3359 4109 4383 3728 4262 3504 3673 3910 2950 3316 3416 3497 2767 [76] 2898 3170 3003 3480 3015 2594 3508 2832 3124 2555 3627 2875 2574 2902 3437 [91] 2925 3067 3014 > postscript(file="/var/www/html/rcomp/tmp/1vfsr1227726767.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 -5 -4 0.236 0.343 0.370 0.333 0.489 0.435 0.396 0.516 0.440 0.447 0.509 0.512 0.487 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 0.587 0.562 0.593 0.912 0.622 0.565 0.590 0.529 0.511 0.526 0.493 0.402 0.513 10 11 12 13 14 15 16 0.458 0.459 0.520 0.393 0.390 0.390 0.308 > 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/2cmdq1227726768.tab") > > system("convert tmp/1vfsr1227726767.ps tmp/1vfsr1227726767.png") > > > proc.time() user system elapsed 0.386 0.172 0.456