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(92,95.9,108.8,103.4,102.1,110.1,83.2,82.7,106.8,113.7,102.5,96.6,92.1,95.6,102.3,98.6,98.2,104.5,84,73.8,103.9,106,97.2,102.6,89,93.8,116.7,106.8,98.5,118.7,90,91.9,113.3,113.1,104.1,108.7,96.7,101,116.9,105.8,99,129.4,83,88.9,115.9,104.2,113.4,112.2,100.8,107.3,126.6,102.9,117.9,128.8,87.5,93.8,122.7,126.2,124.6,116.7,115.2,111.1,129.9,113.3,118.5,137.9,103.6,101.7,127.4,137.5,128.3,118.2,117.1) > x <- c(98.4,99.4,108.8,112.6,104.4,112.2,81.1,97.1,112.6,113.8,107.8,103.2,103.3,101.2,107.7,110.4,101.9,115.9,89.9,88.6,117.2,123.9,100,103.6,94.1,98.7,119.5,112.7,104.4,124.7,89.1,97,121.6,118.8,114,111.5,97.2,102.5,113.4,109.8,104.9,126.1,80,96.8,117.2,112.3,117.3,111.1,102.2,104.3,122.9,107.6,121.3,131.5,89,104.4,128.9,135.9,133.3,121.3,120.5,120.4,137.9,126.1,133.2,151.1,105,119,140.4,156.6,137.1,122.7,125.8) > par7 = '1' > par6 = '0' > par5 = '-0.4' > par4 = '12' > par3 = '1' > par2 = '1' > par1 = '-0.8' > #'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.0007630771 -0.0006893083 -0.0002147520 -0.0001396271 0.0013276617 [6] 0.0022033351 -0.0053814725 0.0033446015 0.0009618331 -0.0036930635 [11] 0.0019256605 -0.0024649448 0.0017417178 0.0029901111 -0.0018868983 [16] 0.0001193557 0.0009927442 -0.0018320597 0.0026632813 -0.0016144461 [21] -0.0017080748 0.0040292599 -0.0013819610 -0.0008989215 0.0001008061 [26] -0.0021101222 0.0005642053 0.0007170686 0.0001182647 -0.0033335166 [31] 0.0030463554 -0.0007503007 -0.0004560838 0.0018977070 -0.0007210196 [36] 0.0013462860 -0.0008376629 0.0013440776 -0.0022454414 0.0037909890 [41] -0.0024549733 0.0022081630 -0.0011777187 0.0001361953 0.0020227711 [46] -0.0013626322 -0.0007286482 0.0018510673 -0.0005159993 -0.0009504570 [51] 0.0011865111 -0.0015889492 0.0007124205 0.0016167948 -0.0012540175 [56] -0.0013223838 0.0009405549 -0.0020793320 -0.0003088878 0.0006696470 > y [1] 0.0001779782 -0.0005052747 -0.0095565802 -0.0075046195 -0.0061694364 [6] -0.0080447783 0.0016293214 -0.0199204736 -0.0042732246 -0.0107070431 [11] -0.0084209276 0.0095677301 -0.0056466274 -0.0030789632 0.0201482049 [16] 0.0125315022 0.0004866735 0.0193439302 0.0115641481 0.0375826415 [21] 0.0132868496 0.0099096092 0.0108441547 0.0089560251 0.0135523478 [26] 0.0118490195 0.0002550411 -0.0014549860 0.0008065283 0.0125545473 [31] -0.0136042302 -0.0054771221 0.0034052279 -0.0125706194 0.0131197938 [36] 0.0048272201 0.0066151050 0.0094371342 0.0116815750 -0.0043306743 [41] 0.0268530510 -0.0006650523 0.0089209240 0.0088181830 0.0084218966 [46] 0.0287485651 0.0139312928 0.0059053332 0.0205424576 0.0053253179 [51] 0.0036921036 0.0147992853 0.0007524685 0.0096457158 0.0273045432 [56] 0.0129378185 0.0054483699 0.0121734375 0.0042224782 0.0018980469 [61] 0.0024419849 > postscript(file="/var/www/html/freestat/rcomp/tmp/1pjxe1228329598.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 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 0.011 -0.030 0.062 -0.047 0.152 -0.079 -0.091 0.292 0.035 -0.134 0.226 -3 -2 -1 0 1 2 3 4 5 6 7 -0.044 -0.066 0.456 -0.464 0.121 0.122 -0.214 0.075 -0.063 -0.201 0.190 8 9 10 11 12 13 14 -0.091 -0.149 0.060 -0.156 0.007 0.078 -0.114 > 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/2hdah1228329598.tab") > > system("convert tmp/1pjxe1228329598.ps tmp/1pjxe1228329598.png") > > > proc.time() user system elapsed 0.548 0.268 1.013