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(2236,2084.9,2409.5,2199.3,2203.5,2254.1,1975.8,1742.2,2520.6,2438.1,2126.3,2267.5,2201.1,2128.5,2596,2458.2,2210.5,2621.2,2231.4,2103.6,2685.8,2539.3,2462.4,2693.3,2307.7,2385.9,2737.6,2653.9,2545.4,2848.8,2359.5,2488.3,2861.1,2717.9,2844,2749,2652.9,2660.2,3187.1,2774.1,3158.2,3244.6,2665.5,2820.8,2983.4,3077.4,3024.8,2731.8,3046.2,2834.8,3292.8,2946.1,3196.9,3284.2,3003,2979,3137.4,3630.2,3270.7,2942.3) > x <- c(3258.1,3140.1,3627.4,3279.4,3204,3515.6,3146.6,2271.7,3627.9,3553.4,3018.3,3355.4,3242,3311.1,4125.2,3423,3120.3,3863,3240.8,2837.4,3945,3684.1,3659.6,3769.6,3592.7,3754,4507.8,3853.2,3817.2,3958.4,3428.9,3125.7,3977,3983.3,4299.6,4306.9,4259.5,3986,4755.6,3925.6,4206.5,4323.4,3816.1,3410.7,4227.4,4296.9,4351.7,3800,4277,4100.2,4672.5,4189.9,4231.9,4654.9,4298.5,3635.9,4505.1,4891.9,4894.2,4093.2) > par7 = '2' > par6 = '2' > par5 = '1' > par4 = '12' > par3 = '2' > par2 = '2' > 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] -292.2 788.9 92.2 -1526.6 1378.5 -717.2 363.6 461.3 -623.4 [10] 294.2 68.6 -720.0 603.1 -299.1 273.2 527.0 -647.7 -131.9 [19] 424.1 -425.7 -398.3 146.0 851.2 136.6 -744.6 735.9 -1078.6 [28] 886.2 -201.7 -283.7 242.1 167.0 -45.1 100.7 > y [1] -331.0 240.4 409.4 -858.5 479.4 138.8 -164.0 80.5 -99.2 [10] -383.7 1024.3 -830.4 512.7 -674.4 736.8 -463.1 119.4 -239.8 [19] 229.3 234.7 -615.6 509.6 -6.9 -268.8 -96.3 639.7 -1021.5 [28] 843.8 169.8 -593.5 411.8 -44.4 -289.8 290.8 > postscript(file="/var/www/html/rcomp/tmp/1vju51228653662.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 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -2 0.153 -0.270 0.174 -0.062 0.113 -0.278 0.278 -0.085 -0.106 0.247 -0.140 -1 0 1 2 3 4 5 6 7 8 9 -0.277 0.594 -0.498 0.160 0.050 -0.061 0.057 0.012 -0.164 0.196 -0.062 10 11 12 -0.086 0.146 -0.210 > 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/25v4b1228653662.tab") > > system("convert tmp/1vju51228653662.ps tmp/1vju51228653662.png") > > > proc.time() user system elapsed 0.389 0.172 0.450