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(108.9,110.5,111.0,110.7,110.0,111.4,107.7,110.4,110.5,106.4,107.5,108.8,107.1,107.9,107.2,106.3,106.7,105.4,109.4,106.7,105.2,107.0,105.4,106.1,105.8,104.2,102.7,102.7,104.9,102.3,104.0,101.2,102.2,101.4,101.1,97.2,99.7,99.4,98.0,103.1,99.4,100.8,96.4,99.7,100.9,101.3,102.6,105.6,107.2,104.0,108.7,104.9,105.3,105.0,106.1,103.7,102.1,97.2,99.5,102.9) > x <- c(137.0,135.9,138.1,137.1,135.1,139.6,131.8,136.7,128.9,131.3,129.5,129.0,129.8,125.4,128.6,130.2,124.6,123.7,124.4,119.2,124.4,123.1,120.9,120.9,117.8,113.6,113.2,115.9,121.1,107.6,114.7,112.8,112.1,109.8,108.5,102.7,110.6,108.2,112.7,107.9,102.7,108.4,108.4,106.9,108.9,103.7,103.6,111.6,105.5,105.5,101.3,103.8,100.3,108.2,105.6,103.0,100.5,104.3,99.1,91.5) > par7 = '0' > par6 = '0' > par5 = '1' > par4 = '1' > 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] 136.0 134.9 137.1 136.1 134.1 138.6 130.8 135.7 127.9 130.3 128.5 128.0 [13] 128.8 124.4 127.6 129.2 123.6 122.7 123.4 118.2 123.4 122.1 119.9 119.9 [25] 116.8 112.6 112.2 114.9 120.1 106.6 113.7 111.8 111.1 108.8 107.5 101.7 [37] 109.6 107.2 111.7 106.9 101.7 107.4 107.4 105.9 107.9 102.7 102.6 110.6 [49] 104.5 104.5 100.3 102.8 99.3 107.2 104.6 102.0 99.5 103.3 98.1 90.5 > y [1] 107.9 109.5 110.0 109.7 109.0 110.4 106.7 109.4 109.5 105.4 106.5 107.8 [13] 106.1 106.9 106.2 105.3 105.7 104.4 108.4 105.7 104.2 106.0 104.4 105.1 [25] 104.8 103.2 101.7 101.7 103.9 101.3 103.0 100.2 101.2 100.4 100.1 96.2 [37] 98.7 98.4 97.0 102.1 98.4 99.8 95.4 98.7 99.9 100.3 101.6 104.6 [49] 106.2 103.0 107.7 103.9 104.3 104.0 105.1 102.7 101.1 96.2 98.5 101.9 > postscript(file="/var/www/html/freestat/rcomp/tmp/1v7xo1228827634.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 -3 -2 0.092 0.154 0.195 0.251 0.260 0.329 0.374 0.441 0.480 0.509 0.534 0.622 0.657 -1 0 1 2 3 4 5 6 7 8 9 10 11 0.712 0.746 0.704 0.689 0.617 0.579 0.535 0.520 0.514 0.497 0.470 0.504 0.429 12 13 14 0.449 0.462 0.452 > 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/2395n1228827635.tab") > > system("convert tmp/1v7xo1228827634.ps tmp/1v7xo1228827634.png") > > > proc.time() user system elapsed 0.544 0.227 0.633