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(99.5,93.5,104.6,95.3,102.8,103.3,100.2,107.9,107.5,119.8,112,102.1,105.3,101.3,108.4,107.4,109.1,109.5,111.4,110.1,117,129.6,113.5,113.3,110.1,107.4,110.1,112.5,106,117.6,117.8,113.5,121.2,130.4,115.2,117.9,110.7,107.6,124.3,115.1,112.5,127.9,117.4,119.3,130.4,126,125.4,130.5,115.9,108.7,124,119.4,118.6,131.3,111.1,124.8,132.3,126.7,131.7,130.9,122.1,113.2,133.6,119.2,129.4,131.4,117.1,130.5,132.3,140.8,137.5,128.6,126.7,120.8,139.3,128.6,131.3,136.3,128.8,133.2,136.3,151.1,145,134.4) > x <- c(2648.9,2669.6,3042.3,2604.2,2732.1,2621.7,2483.7,2479.3,2684.6,2834.7,2566.1,2251.2,2350,2299.8,2542.8,2530.2,2508.1,2616.8,2534.1,2181.8,2578.9,2841.9,2529.9,2103.2,2326.2,2452.6,2782.1,2727.3,2648.2,2760.7,2613,2225.4,2713.9,2923.3,2707,2473.9,2521,2531.8,3068.8,2826.9,2674.2,2966.6,2798.8,2629.6,3124.6,3115.7,3083,2863.9,2728.7,2789.4,3225.7,3148.2,2836.5,3153.5,2656.9,2834.7,3172.5,2998.8,3103.1,2735.6,2818.1,2874.4,3438.5,2949.1,3306.8,3530,3003.8,3206.4,3514.6,3522.6,3525.5,2996.2,3231.1,3030,3541.7,3113.2,3390.8,3424.2,3079.8,3123.4,3317.1,3579.9,3317.9,2668.1) > 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] 2647.9 2668.6 3041.3 2603.2 2731.1 2620.7 2482.7 2478.3 2683.6 2833.7 [11] 2565.1 2250.2 2349.0 2298.8 2541.8 2529.2 2507.1 2615.8 2533.1 2180.8 [21] 2577.9 2840.9 2528.9 2102.2 2325.2 2451.6 2781.1 2726.3 2647.2 2759.7 [31] 2612.0 2224.4 2712.9 2922.3 2706.0 2472.9 2520.0 2530.8 3067.8 2825.9 [41] 2673.2 2965.6 2797.8 2628.6 3123.6 3114.7 3082.0 2862.9 2727.7 2788.4 [51] 3224.7 3147.2 2835.5 3152.5 2655.9 2833.7 3171.5 2997.8 3102.1 2734.6 [61] 2817.1 2873.4 3437.5 2948.1 3305.8 3529.0 3002.8 3205.4 3513.6 3521.6 [71] 3524.5 2995.2 3230.1 3029.0 3540.7 3112.2 3389.8 3423.2 3078.8 3122.4 [81] 3316.1 3578.9 3316.9 2667.1 > y [1] 98.5 92.5 103.6 94.3 101.8 102.3 99.2 106.9 106.5 118.8 111.0 101.1 [13] 104.3 100.3 107.4 106.4 108.1 108.5 110.4 109.1 116.0 128.6 112.5 112.3 [25] 109.1 106.4 109.1 111.5 105.0 116.6 116.8 112.5 120.2 129.4 114.2 116.9 [37] 109.7 106.6 123.3 114.1 111.5 126.9 116.4 118.3 129.4 125.0 124.4 129.5 [49] 114.9 107.7 123.0 118.4 117.6 130.3 110.1 123.8 131.3 125.7 130.7 129.9 [61] 121.1 112.2 132.6 118.2 128.4 130.4 116.1 129.5 131.3 139.8 136.5 127.6 [73] 125.7 119.8 138.3 127.6 130.3 135.3 127.8 132.2 135.3 150.1 144.0 133.4 > postscript(file="/var/www/html/rcomp/tmp/1aaij1229017986.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.180 0.237 0.323 0.365 0.496 0.361 0.241 0.388 0.380 0.473 0.553 0.540 0.464 -3 -2 -1 0 1 2 3 4 5 6 7 8 9 0.529 0.556 0.609 0.793 0.522 0.427 0.537 0.472 0.584 0.609 0.531 0.476 0.499 10 11 12 13 14 15 16 0.470 0.521 0.614 0.386 0.312 0.327 0.268 > 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/26vv01229017986.tab") > > system("convert tmp/1aaij1229017986.ps tmp/1aaij1229017986.png") > > > proc.time() user system elapsed 0.396 0.172 0.602