R version 2.7.0 (2008-04-22) 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(93,98.4,92.6,94.6,99.5,97.6,91.3,93.6,93.1,78.4,70.2,69.3,71.1,73.5,85.9,91.5,91.8,88.3,91.3,94,99.3,96.7,88,96.7,106.8,114.3,105.7,90.1,91.6,97.7,100.8,104.6,95.9,102.7,104,107.9,113.8,113.8,123.1,125.1,137.6,134,140.3,152.1,150.6,167.3,153.2,142,154.4,158.5,180.9,181.3,172.4,192,199.3,215.4,214.3,201.5,190.5,196) > x <- c(99.4,97.5,94.6,92.6,92.5,89.8,88.8,87.4,85.2,83.1,84.7,84.8,85.8,86.3,89,89,89.3,91.9,94.9,94.4,96.8,96.9,98,97.9,100.9,103.9,103.1,102.5,104.3,102.6,101.7,102.8,105.4,110.9,113.5,116.3,124,128.8,133.5,132.6,128.4,127.3,126.7,123.3,123.2,124.4,128.2,128.7,135.7,139,145.4,142.4,137.7,137,137.1,139.3,139.6,140.4,142.3,148.3) > par7 = '1' > par6 = '1' > par5 = '-0.1' > par4 = '12' > par3 = '1' > par2 = '1' > par1 = '1.9' > #'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] 145.76595 327.75914 118.89881 22.95478 306.82914 234.99055 [7] 48.78978 266.99077 119.57061 -18.38921 -11.62962 133.58090 [13] 165.81245 -203.36385 -38.81012 99.97179 -260.68978 -235.88860 [19] 100.83386 24.67030 366.24616 114.14549 206.38429 384.84253 [25] 180.57771 430.58245 -34.61689 -453.78349 24.00635 10.94038 [31] -333.04783 -177.70536 -280.62159 113.87613 -160.67000 -5.29827 [37] -96.89762 175.83428 -189.22170 -64.81852 27.81273 55.32238 [43] 447.96757 33.14844 -23.42597 -132.14298 490.37095 > y [1] -0.014132992 0.139164689 0.026758920 -0.029876643 -0.012602789 [6] 0.063654269 0.002707931 0.038130854 0.093377289 0.011851762 [11] 0.068406843 0.045819352 0.020759986 -0.149544485 -0.141332519 [16] 0.008434876 0.065690060 -0.001584865 0.004757250 -0.089510441 [21] 0.060032119 0.067877262 -0.036872093 -0.029333812 -0.042397391 [26] 0.097626504 0.110953120 0.047962854 -0.057127888 0.008363341 [31] 0.025771300 0.048782963 0.020099156 -0.060909275 -0.069169430 [36] 0.017542719 0.015812460 0.030391285 -0.008638319 -0.088481773 [41] 0.080217108 -0.006070768 -0.003485709 0.003006921 -0.099475005 [46] 0.019882324 0.062888613 > postscript(file="/var/www/html/rcomp/tmp/1rgz71228247295.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 -13 -12 -11 -10 -9 -8 -7 -6 -5 -4 -3 -0.161 0.004 -0.018 -0.129 -0.091 -0.078 0.132 0.181 0.108 0.126 0.180 -2 -1 0 1 2 3 4 5 6 7 8 -0.020 0.217 0.212 -0.192 0.009 0.127 0.070 -0.117 -0.116 -0.185 -0.089 9 10 11 12 13 -0.242 -0.027 -0.077 -0.085 0.175 > 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/29dhl1228247295.tab") > > system("convert tmp/1rgz71228247295.ps tmp/1rgz71228247295.png") > > > proc.time() user system elapsed 1.174 0.298 1.229