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(1530.9,2220.6,2161.5,1863.6,1955.1,1907.4,1889.4,2246.3,2213,1965,2285.6,1983.8,1872.4,2371.4,2287,2198.2,2330.4,2014.4,2066.1,2355.8,2232.5,2091.7,2376.5,1931.9,2025.7,2404.9,2316.1,2368.1,2282.5,2158.6,2174.8,2594.1,2281.4,2547.9,2606.3,2190.8,2262.3,2423.8,2520.4,2482.9,2215.9,2441.9,2333.8,2670.2,2431,2559.3,2661.4,2404.6,2378.3,2489.2,2959,2713.5,2341.3,2833.2,2849.7,2871.7,3058.3,2855.1,3083.6,2828.3) > x <- c(1846.5,2796.3,2895.6,2472.2,2584.4,2630.4,2663.1,3176.2,2856.7,2551.4,3088.7,2628.3,2226.2,3023.6,3077.9,3084.1,2990.3,2949.6,3014.7,3517.7,3121.2,3067.4,3174.6,2676.3,2424,3195.1,3146.6,3506.7,3528.5,3365.1,3153,3843.3,3123.2,3361.1,3481.9,2970.5,2537,3257.6,3301.3,3391.6,2933.6,3283.2,3139.7,3486.4,3202.2,3294.4,3550.3,3279.3,2678.6,3451.4,3977.1,3814.8,3310.5,3971.8,4051.9,4057.6,4391.4,3628.9,4092.2,3822.5) > par7 = '1' > par6 = '0' > par5 = '0.7' > par4 = '12' > par3 = '1' > par2 = '1' > par1 = '0.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] -0.226957779 -0.037595654 0.352536638 -0.166030829 -0.069229663 [6] 0.021415574 -0.044698159 -0.032787962 0.210222057 -0.345977921 [11] -0.021540954 0.144969244 -0.061481246 -0.073957248 0.239276375 [16] 0.082889066 -0.076577111 -0.194767543 0.101030536 -0.199759725 [21] 0.203585219 0.002871894 0.022936190 -0.131271850 -0.056097536 [26] 0.064193368 -0.183014386 -0.338718159 0.358647245 0.045977198 [31] -0.211947592 0.277329652 -0.101026192 0.089118928 0.177103394 [36] -0.101856081 0.010870858 0.292518499 -0.155995506 0.003540494 [41] 0.161758260 0.145979106 -0.232326282 0.373585795 -0.500755593 [46] 0.105570431 0.023031646 > y [1] 36.678779 14.795861 12.431145 34.073080 37.610074 11.006980 18.131824 [8] 10.736242 1.931826 12.902126 8.877877 -5.341196 15.799340 3.248087 [15] 2.852909 16.698296 -4.693052 14.560405 10.922440 22.862283 4.822315 [22] 44.647173 22.002755 26.242065 23.699181 1.826510 19.736421 11.079427 [29] -6.574640 27.785694 15.686597 7.166339 14.564528 1.083326 5.187730 [36] 20.973980 11.345206 6.287641 40.826204 21.802845 12.331573 36.838782 [43] 48.839161 18.686320 58.384764 27.626534 38.742975 39.988050 > postscript(file="/var/www/html/freestat/rcomp/tmp/1r9sl1228308790.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.229 -0.193 0.092 0.227 0.015 0.037 0.316 -0.115 0.084 0.120 -0.085 -2 -1 0 1 2 3 4 5 6 7 8 -0.054 0.456 -0.500 0.085 0.136 -0.261 -0.037 0.090 -0.325 0.140 0.120 9 10 11 12 13 -0.224 0.161 0.165 -0.085 0.008 > 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/2tday1228308790.tab") > > system("convert tmp/1r9sl1228308790.ps tmp/1r9sl1228308790.png") > > > proc.time() user system elapsed 0.544 0.210 0.631