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(94.6,97.9,101.7,102.3,103.5,103.6,102.3,101.6,104.3,110.8,112.1,111.1,114.4,115,115.3,114.1,114.8,114.5,114.1,112.3,113,112.2,113.7,113.6,115.8,117.9,120.1,118.8,114.7,110.9,112.9,113.3,114.3,116.5,114.3,115.9,120.1,122.6,122.4,123.1,127.9,130.9,135,134.9,130.2,130.8,132.6,138.6,146.2,149.3,149.9,156.8,158.8,156.7,159.9,158.2,157.5,159.1,160.6,161.6,161.3,159.7,162.4,161.4,161.7,164.3,165.4,156.6,151.5,131.3) > x <- c(115.6,120.3,121.9,121.7,118.9,113.4,114,117.5,120.9,125.1,124.7,128.2,149.7,163.6,173.9,164.5,154.2,147.9,159.3,170.3,170,174.2,190.8,179.9,240.8,241.9,241.1,239.6,220.8,209.3,209.9,228.3,242.1,226.4,231.5,229.7,257.6,260,264.4,268.8,271.4,273.8,277.4,268.2,264.6,266.6,266,267.4,289.8,294,310.3,311.7,302.1,298.2,299.2,296.2,299,300,299.4,300.2,470.2,472.1,484.8,513.4,547.2,548.1,544.7,521.1,459,413.2) > 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] 114.6 119.3 120.9 120.7 117.9 112.4 113.0 116.5 119.9 124.1 123.7 127.2 [13] 148.7 162.6 172.9 163.5 153.2 146.9 158.3 169.3 169.0 173.2 189.8 178.9 [25] 239.8 240.9 240.1 238.6 219.8 208.3 208.9 227.3 241.1 225.4 230.5 228.7 [37] 256.6 259.0 263.4 267.8 270.4 272.8 276.4 267.2 263.6 265.6 265.0 266.4 [49] 288.8 293.0 309.3 310.7 301.1 297.2 298.2 295.2 298.0 299.0 298.4 299.2 [61] 469.2 471.1 483.8 512.4 546.2 547.1 543.7 520.1 458.0 412.2 > y [1] 93.6 96.9 100.7 101.3 102.5 102.6 101.3 100.6 103.3 109.8 111.1 110.1 [13] 113.4 114.0 114.3 113.1 113.8 113.5 113.1 111.3 112.0 111.2 112.7 112.6 [25] 114.8 116.9 119.1 117.8 113.7 109.9 111.9 112.3 113.3 115.5 113.3 114.9 [37] 119.1 121.6 121.4 122.1 126.9 129.9 134.0 133.9 129.2 129.8 131.6 137.6 [49] 145.2 148.3 148.9 155.8 157.8 155.7 158.9 157.2 156.5 158.1 159.6 160.6 [61] 160.3 158.7 161.4 160.4 160.7 163.3 164.4 155.6 150.5 130.3 > postscript(file="/var/www/html/freestat/rcomp/tmp/12l1p1228232003.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 -15 -14 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 0.267 0.282 0.296 0.310 0.324 0.335 0.349 0.387 0.433 0.491 0.549 0.610 0.676 -2 -1 0 1 2 3 4 5 6 7 8 9 10 0.742 0.804 0.857 0.867 0.852 0.829 0.799 0.770 0.744 0.714 0.688 0.661 0.627 11 12 13 14 15 0.589 0.550 0.505 0.455 0.404 > 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/26ixu1228232003.tab") > > system("convert tmp/12l1p1228232003.ps tmp/12l1p1228232003.png") > > > proc.time() user system elapsed 0.547 0.215 0.616