R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-bit) 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(-67.48769 + ,-64.93435 + ,-62.09455 + ,-59.24374 + ,-56.24434 + ,-53.29357 + ,-50.24352 + ,-47.21371 + ,-44.31956 + ,-41.40615 + ,-38.67882 + ,-36.07201 + ,-33.53312 + ,-31.24318 + ,-29.06622 + ,-27.10601 + ,-25.44346 + ,-23.95676 + ,-22.79198 + ,-21.83444 + ,-21.21284 + ,-20.82125 + ,-20.76539 + ,-20.99605 + ,-21.44044 + ,-22.24562 + ,-23.3189 + ,-24.66141 + ,-26.26336 + ,-28.08825 + ,-30.15747 + ,-32.43541 + ,-34.91399 + ,-37.57035 + ,-40.37001 + ,-43.2971 + ,-46.32778 + ,-49.41776 + ,-52.56352 + ,-55.74308 + ,-58.90207 + ,-62.03418 + ,-65.11547 + ,-68.08083 + ,-70.93258 + ,-73.63394 + ,-76.16604 + ,-78.49364 + ,-80.59772 + ,-82.46155 + ,-84.05849 + ,-85.37479 + ,-86.38548 + ,-87.08258 + ,-87.44406 + ,-87.47346 + ,-87.14482 + ,-86.47578 + ,-85.43721 + ,-84.05641 + ,-82.30603 + ,-80.19695 + ,-77.77158 + ,-74.98702 + ,-71.90565 + ,-68.5277 + ,-64.824 + ,-60.87651 + ,-56.64985 + ,-52.18774 + ,-47.56321 + ,-42.72731 + ,-37.76972 + ,-32.66815 + ,-27.50522 + ,-22.30677 + ,-17.01678 + ,-11.75518 + ,-6.494408 + ,-1.300473 + ,3.773934 + ,8.736804 + ,13.53007 + ,18.14927 + ,22.54604 + ,26.70576 + ,30.59934 + ,34.20228 + ,37.48168 + ,40.43245 + ,43.04378 + ,45.2574 + ,47.12449 + ,48.55617 + ,49.63199 + ,50.30155 + ,50.50163 + ,50.3484 + ,49.71404 + ,48.66773 + ,47.20958 + ,45.52402 + ,43.37497 + ,40.76828 + ,37.89896 + ,34.59856 + ,31.07775 + ,27.26912 + ,23.08356 + ,18.6522 + ,14.00902 + ,9.275627 + ,4.388309 + ,-0.7375945 + ,-5.85959 + ,-11.15065 + ,-16.37748 + ,-21.49657 + ,-26.80144 + ,-32.05593 + ,-37.20892 + ,-42.15165 + ,-46.9585 + ,-51.67009 + ,-56.10513 + ,-60.32025 + ,-64.29823 + ,-68.01822 + ,-71.50566 + ,-74.64172 + ,-77.55137 + ,-80.04708 + ,-82.2119 + ,-84.0584 + ,-85.54139 + ,-86.68427 + ,-87.47647 + ,-87.92064 + ,-88.03718 + ,-87.83202 + ,-87.28342 + ,-86.42725 + ,-85.27068 + ,-83.88298 + ,-82.24538 + ,-80.32531) > x <- c(0.1358 + ,0.1387 + ,0.1363 + ,0.1377 + ,0.1407 + ,0.1422 + ,0.1431 + ,0.1446 + ,0.1461 + ,0.1466 + ,0.1471 + ,0.1475 + ,0.1475 + ,0.1485 + ,0.1475 + ,0.148 + ,0.148 + ,0.1485 + ,0.1475 + ,0.148 + ,0.148 + ,0.1485 + ,0.1485 + ,0.148 + ,0.149 + ,0.1485 + ,0.148 + ,0.1475 + ,0.1471 + ,0.1471 + ,0.1456 + ,0.1456 + ,0.1451 + ,0.1451 + ,0.1446 + ,0.1446 + ,0.1446 + ,0.1451 + ,0.1441 + ,0.1441 + ,0.1436 + ,0.1436 + ,0.1436 + ,0.1431 + ,0.1431 + ,0.1436 + ,0.1431 + ,0.1426 + ,0.1431 + ,0.1431 + ,0.1426 + ,0.1426 + ,0.1422 + ,0.1422 + ,0.1422 + ,0.1426 + ,0.1426 + ,0.1422 + ,0.1417 + ,0.1417 + ,0.1422 + ,0.1422 + ,0.1426 + ,0.1422 + ,0.1422 + ,0.1422 + ,0.1422 + ,0.1422 + ,0.1431 + ,0.1426 + ,0.1426 + ,0.1422 + ,0.1422 + ,0.1426 + ,0.1422 + ,0.1426 + ,0.1426 + ,0.1426 + ,0.1426 + ,0.1426 + ,0.1422 + ,0.1422 + ,0.1426 + ,0.1426 + ,0.1422 + ,0.1422 + ,0.1426 + ,0.1426 + ,0.1422 + ,0.1422 + ,0.1426 + ,0.1422 + ,0.1426 + ,0.1422 + ,0.1422 + ,0.1417 + ,0.1422 + ,0.1422 + ,0.1417 + ,0.1426 + ,0.1417 + ,0.1412 + ,0.1422 + ,0.1417 + ,0.1407 + ,0.1407 + ,0.1402 + ,0.1407 + ,0.1407 + ,0.1407 + ,0.1402 + ,0.1397 + ,0.1397 + ,0.1397 + ,0.1397 + ,0.1392 + ,0.1387 + ,0.1392 + ,0.1387 + ,0.1392 + ,0.1382 + ,0.1392 + ,0.1377 + ,0.1377 + ,0.1382 + ,0.1382 + ,0.1382 + ,0.1373 + ,0.1373 + ,0.1373 + ,0.1377 + ,0.1373 + ,0.1373 + ,0.1373 + ,0.1368 + ,0.1363 + ,0.1368 + ,0.1368 + ,0.1363 + ,0.1358 + ,0.1353 + ,0.1353 + ,0.1343 + ,0.1348 + ,0.1343 + ,0.1343) > par8 = 'na.pass' > par7 = '0' > par6 = '0' > par5 = '1' > par4 = '1' > par3 = '0' > par2 = '0' > par1 = '1' > ylab = 'y' > xlab = 'x' > par8 <- 'na.pass' > par7 <- '0' > par6 <- '0' > par5 <- '1' > par4 <- '1' > par3 <- '0' > par2 <- '0' > par1 <- '1' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), Cross Correlation Function (v1.0.8) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_cross.wasp/ > #Source of accompanying publication: > # > 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 (par8=='na.fail') par8 <- na.fail else par8 <- na.pass > ccf <- function (x, y, lag.max = NULL, type = c('correlation', 'covariance'), plot = TRUE, na.action = na.fail, ...) { + type <- match.arg(type) + if (is.matrix(x) || is.matrix(y)) + stop('univariate time series only') + X <- na.action(ts.intersect(as.ts(x), as.ts(y))) + colnames(X) <- c(deparse(substitute(x))[1L], deparse(substitute(y))[1L]) + acf.out <- acf(X, lag.max = lag.max, plot = FALSE, type = type, na.action=na.action) + lag <- c(rev(acf.out$lag[-1, 2, 1]), acf.out$lag[, 1, 2]) + y <- c(rev(acf.out$acf[-1, 2, 1]), acf.out$acf[, 1, 2]) + acf.out$acf <- array(y, dim = c(length(y), 1L, 1L)) + acf.out$lag <- array(lag, dim = c(length(y), 1L, 1L)) + acf.out$snames <- paste(acf.out$snames, collapse = ' & ') + if (plot) { + plot(acf.out, ...) + return(invisible(acf.out)) + } + else return(acf.out) + } > 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.8642 -0.8613 -0.8637 -0.8623 -0.8593 -0.8578 -0.8569 -0.8554 -0.8539 [10] -0.8534 -0.8529 -0.8525 -0.8525 -0.8515 -0.8525 -0.8520 -0.8520 -0.8515 [19] -0.8525 -0.8520 -0.8520 -0.8515 -0.8515 -0.8520 -0.8510 -0.8515 -0.8520 [28] -0.8525 -0.8529 -0.8529 -0.8544 -0.8544 -0.8549 -0.8549 -0.8554 -0.8554 [37] -0.8554 -0.8549 -0.8559 -0.8559 -0.8564 -0.8564 -0.8564 -0.8569 -0.8569 [46] -0.8564 -0.8569 -0.8574 -0.8569 -0.8569 -0.8574 -0.8574 -0.8578 -0.8578 [55] -0.8578 -0.8574 -0.8574 -0.8578 -0.8583 -0.8583 -0.8578 -0.8578 -0.8574 [64] -0.8578 -0.8578 -0.8578 -0.8578 -0.8578 -0.8569 -0.8574 -0.8574 -0.8578 [73] -0.8578 -0.8574 -0.8578 -0.8574 -0.8574 -0.8574 -0.8574 -0.8574 -0.8578 [82] -0.8578 -0.8574 -0.8574 -0.8578 -0.8578 -0.8574 -0.8574 -0.8578 -0.8578 [91] -0.8574 -0.8578 -0.8574 -0.8578 -0.8578 -0.8583 -0.8578 -0.8578 -0.8583 [100] -0.8574 -0.8583 -0.8588 -0.8578 -0.8583 -0.8593 -0.8593 -0.8598 -0.8593 [109] -0.8593 -0.8593 -0.8598 -0.8603 -0.8603 -0.8603 -0.8603 -0.8608 -0.8613 [118] -0.8608 -0.8613 -0.8608 -0.8618 -0.8608 -0.8623 -0.8623 -0.8618 -0.8618 [127] -0.8618 -0.8627 -0.8627 -0.8627 -0.8623 -0.8627 -0.8627 -0.8627 -0.8632 [136] -0.8637 -0.8632 -0.8632 -0.8637 -0.8642 -0.8647 -0.8647 -0.8657 -0.8652 [145] -0.8657 -0.8657 > y [1] -68.487690 -65.934350 -63.094550 -60.243740 -57.244340 -54.293570 [7] -51.243520 -48.213710 -45.319560 -42.406150 -39.678820 -37.072010 [13] -34.533120 -32.243180 -30.066220 -28.106010 -26.443460 -24.956760 [19] -23.791980 -22.834440 -22.212840 -21.821250 -21.765390 -21.996050 [25] -22.440440 -23.245620 -24.318900 -25.661410 -27.263360 -29.088250 [31] -31.157470 -33.435410 -35.913990 -38.570350 -41.370010 -44.297100 [37] -47.327780 -50.417760 -53.563520 -56.743080 -59.902070 -63.034180 [43] -66.115470 -69.080830 -71.932580 -74.633940 -77.166040 -79.493640 [49] -81.597720 -83.461550 -85.058490 -86.374790 -87.385480 -88.082580 [55] -88.444060 -88.473460 -88.144820 -87.475780 -86.437210 -85.056410 [61] -83.306030 -81.196950 -78.771580 -75.987020 -72.905650 -69.527700 [67] -65.824000 -61.876510 -57.649850 -53.187740 -48.563210 -43.727310 [73] -38.769720 -33.668150 -28.505220 -23.306770 -18.016780 -12.755180 [79] -7.494408 -2.300473 2.773934 7.736804 12.530070 17.149270 [85] 21.546040 25.705760 29.599340 33.202280 36.481680 39.432450 [91] 42.043780 44.257400 46.124490 47.556170 48.631990 49.301550 [97] 49.501630 49.348400 48.714040 47.667730 46.209580 44.524020 [103] 42.374970 39.768280 36.898960 33.598560 30.077750 26.269120 [109] 22.083560 17.652200 13.009020 8.275627 3.388309 -1.737595 [115] -6.859590 -12.150650 -17.377480 -22.496570 -27.801440 -33.055930 [121] -38.208920 -43.151650 -47.958500 -52.670090 -57.105130 -61.320250 [127] -65.298230 -69.018220 -72.505660 -75.641720 -78.551370 -81.047080 [133] -83.211900 -85.058400 -86.541390 -87.684270 -88.476470 -88.920640 [139] -89.037180 -88.832020 -88.283420 -87.427250 -86.270680 -84.882980 [145] -83.245380 -81.325310 > postscript(file="/var/wessaorg/rcomp/tmp/1q67m1414747966.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > (r <- ccf(x,y,na.action=par8,main='Cross Correlation Function',ylab='CCF',xlab='Lag (k)')) Autocorrelations of series 'X', by lag -18 -17 -16 -15 -14 -13 -12 -11 -10 -9 -8 -0.011 0.012 0.033 0.054 0.075 0.094 0.113 0.132 0.150 0.166 0.180 -7 -6 -5 -4 -3 -2 -1 0 1 2 3 0.194 0.206 0.218 0.228 0.237 0.244 0.249 0.252 0.226 0.202 0.170 4 5 6 7 8 9 10 11 12 13 14 0.137 0.107 0.076 0.044 0.013 -0.017 -0.048 -0.078 -0.109 -0.140 -0.169 15 16 17 18 -0.200 -0.230 -0.259 -0.287 > dev.off() null device 1 > > #Note: the /var/wessaorg/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/wessaorg/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/wessaorg/rcomp/tmp/2gcr11414747966.tab") > > try(system("convert tmp/1q67m1414747966.ps tmp/1q67m1414747966.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.616 0.075 0.694