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(104.0,107.9,113.8,113.8,123.1,125.1,137.6,134.0,140.3,152.1,150.6,167.3,153.2,142.0,154.4,158.5,180.9,181.3,172.4,192.0,199.3,215.4,214.3,201.5,190.5,196.0,215.7,209.4,214.1,237.8,239.0,237.8,251.5,248.8,215.4,201.2,203.1,214.2,188.9,203.0,213.3,228.5,228.2,240.9,258.8,248.5,269.2,289.6,323.4,317.2,322.8,340.9,368.2,388.5,441.2,474.3,483.9,417.9,365.9,263.0) > x <- c(118.4,121.4,128.8,131.7,141.7,142.9,139.4,134.7,125.0,113.6,111.5,108.5,112.3,116.6,115.5,120.1,132.9,128.1,129.3,132.5,131.0,124.9,120.8,122.0,122.1,127.4,135.2,137.3,135.0,136.0,138.4,134.7,138.4,133.9,133.6,141.2,151.8,155.4,156.6,161.6,160.7,156.0,159.5,168.7,169.9,169.9,185.9,190.8,195.8,211.9,227.1,251.3,256.7,251.9,251.2,270.3,267.2,243.0,229.9,187.2) > par7 = '0' > par6 = '2' > par5 = '1' > par4 = '12' > par3 = '0' > 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] 4.4 -4.5 7.1 -8.8 -4.7 -1.2 -5.0 -1.7 9.3 -0.9 6.8 0.5 [13] -5.4 5.7 8.2 -17.6 6.0 2.0 -4.7 -4.6 2.0 5.3 -1.1 5.2 [25] 2.5 -5.7 -4.4 3.3 1.4 -6.1 7.4 -8.2 4.2 7.9 3.0 -7.0 [37] -2.4 3.8 -5.9 -3.8 8.2 5.7 -8.0 -1.2 16.0 -11.1 0.1 11.1 [49] -0.9 9.0 -18.8 -10.2 4.1 19.8 -22.2 -21.1 11.1 -29.6 > y [1] 2.0 -5.9 9.3 -7.3 10.5 -16.1 9.9 5.5 -13.3 18.2 -30.8 2.9 [13] 23.6 -8.3 18.3 -22.0 -9.3 28.5 -12.3 8.8 -17.2 -11.7 1.8 16.5 [25] 14.2 -26.0 11.0 19.0 -22.5 -2.4 14.9 -16.4 -30.7 19.2 16.1 9.2 [37] -36.4 39.4 -3.8 4.9 -15.5 13.0 5.2 -28.2 31.0 -0.3 13.4 -40.0 [49] 11.8 12.5 9.2 -7.0 32.4 -19.6 -23.5 -75.6 14.0 -50.9 > postscript(file="/var/www/html/freestat/rcomp/tmp/1qfyi1228292234.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.021 -0.046 0.122 -0.142 0.005 0.059 -0.177 0.096 -0.086 0.145 0.056 -3 -2 -1 0 1 2 3 4 5 6 7 0.156 -0.174 0.087 0.366 -0.156 0.093 0.128 0.101 -0.151 -0.126 0.222 8 9 10 11 12 13 14 -0.087 -0.107 0.185 -0.023 -0.015 -0.244 0.215 > 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/2vwrg1228292234.tab") > > system("convert tmp/1qfyi1228292234.ps tmp/1qfyi1228292234.png") > > > proc.time() user system elapsed 0.550 0.223 0.617