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(44028,45564,44277,44976,45406,47379,49200,50221,51573,53091,53337,54978,57885,67099,67169,69796,70600,71982,73957,75273,76322,77078,77954,79238,82179,83834,83744,84861,86478,88290,90287,91230,92380,92506,94172,94728,96581,97344,98346,98214,98366,98768,99832,99976,99961,100164,99964,99304,104008,104644,103950,104263,104241,105141,106018,105866,105944,106379,105082,104915,107026) > x <- c(150739,159129,157928,147768,137507,136919,136151,133001,125554,119647,114158,116193,152803,161761,160942,149470,139208,134588,130322,126611,122401,117352,112135,112879,148729,157230,157221,146681,136524,132111,125326,122716,116615,113719,110737,112093,143565,149946,149147,134339,122683,115614,116566,111272,104609,101802,94542,93051,124129,130374,123946,114971,105531,104919,104782,101281,94545,93248,84031,87486,115867) > par7 = '1' > par6 = '1' > par5 = '1' > par4 = '1' > par3 = '1' > par2 = '1' > 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] -9591 -8959 -101 9673 -180 -2382 -4297 1540 418 7524 [11] 34575 -27652 -9777 -10653 1210 5642 354 555 -499 -839 [21] -168 5961 35106 -27349 -8510 -10531 383 5744 -2372 4175 [31] -3491 3205 -86 4338 30116 -25091 -7180 -14009 3152 4587 [41] 8021 -6246 -1369 3856 -4453 5769 32569 -24833 -12673 -2547 [51] -465 8828 475 -3364 -3235 5439 -7920 12672 24926 > y [1] -2823 1986 -269 1543 -152 -800 331 166 -1272 1395 1266 6307 [13] -9144 2557 -1823 578 593 -659 -267 -293 120 408 1657 -1286 [25] -1745 1207 500 195 185 -1054 207 -1024 1540 -1110 1297 -1090 [37] 239 -1134 284 250 662 -920 -159 218 -403 -460 5364 -4068 [49] -1330 1007 -335 922 -23 -1029 230 357 -1732 1130 2278 > postscript(file="/var/www/html/rcomp/tmp/1cq1z1229687081.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.124 -0.068 0.404 -0.109 -0.061 -0.173 0.037 -0.034 0.177 -0.026 -0.060 -3 -2 -1 0 1 2 3 4 5 6 7 0.070 -0.386 0.240 0.354 -0.055 -0.118 -0.118 0.006 -0.065 0.161 0.043 8 9 10 11 12 13 14 -0.064 0.095 -0.486 0.331 0.148 0.021 -0.070 > 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/2j6bb1229687081.tab") > > system("convert tmp/1cq1z1229687081.ps tmp/1cq1z1229687081.png") > > > proc.time() user system elapsed 0.396 0.170 0.456