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(3431,3874,2617,3580,5267,3832,3441,3228,3397,3971,4625,4486,4131,4686,3174,4282,4209,4159,3936,3153,3620,4227,4441,4808,4850,5040,3546,4669,5410,5134,4864,3999,4459,4622,5360,4658,5173,4845,3325,4720,4895,5071,4895,3805,4187,4435,4475,4774,5161,4529,3284,4303,4610,4691,4200,3471,3132,4226,3723,3576,3397) > x <- c(10,12,12,13,17,12,15,12,14,19,16,17,16,19,17,17,20,18,16,19,18,23,20,20,15,17,16,15,10,13,10,19,21,17,16,17,14,18,17,14,15,16,11,15,13,17,16,9,17,15,12,12,12,12,4,7,4,3,3,0,5) > 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] 9 11 11 12 16 11 14 11 13 18 15 16 15 18 16 16 19 17 15 18 17 22 19 19 14 [26] 16 15 14 9 12 9 18 20 16 15 16 13 17 16 13 14 15 10 14 12 16 15 8 16 14 [51] 11 11 11 11 3 6 3 2 2 -1 4 > y [1] 3430 3873 2616 3579 5266 3831 3440 3227 3396 3970 4624 4485 4130 4685 3173 [16] 4281 4208 4158 3935 3152 3619 4226 4440 4807 4849 5039 3545 4668 5409 5133 [31] 4863 3998 4458 4621 5359 4657 5172 4844 3324 4719 4894 5070 4894 3804 4186 [46] 4434 4474 4773 5160 4528 3283 4302 4609 4690 4199 3470 3131 4225 3722 3575 [61] 3396 > postscript(file="/var/www/html/rcomp/tmp/14qur1228159288.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.253 0.198 0.154 0.127 0.081 0.205 0.230 0.179 0.124 0.139 0.189 -3 -2 -1 0 1 2 3 4 5 6 7 0.241 0.330 0.262 0.245 0.131 0.028 0.057 0.139 -0.050 -0.149 -0.160 8 9 10 11 12 13 14 -0.104 -0.021 -0.101 -0.213 -0.212 -0.270 -0.281 > 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/2hwkt1228159288.tab") > > system("convert tmp/14qur1228159288.ps tmp/14qur1228159288.png") > > > proc.time() user system elapsed 0.383 0.169 0.460