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. > x <- c(1095,1085,1075,1054,1261,1250,1095,992,1002,1002,1013,1033,1095,1075,1106,1157,1447,1447,1385,1323,1374,1436,1447,1478,1571,1509,1509,1602,1860,1881,1829,1705,1798,1798,1808,1860,1901,1922,1922,1984,2222,2284,2294,2139,2222,2191,2129,2263,2294,2242,2253,2325,2594,2728,2728,2666,2759,2666,2614,2811,2842,2769,2955,3028,3245,3389,3369,3358,3441,3431,3307,3493,3555,3493,3751,3875,4164,4278,4247,4185,4237,4299,4092,4257,4361,4319,4588,4681,5074,5146,5053,5105,5136,5167,4970,5156,5259,5156,5456,5549,5952,6014,6034,6138,6138,6179,5993,6086,6148,6034,6365,6427,6840,6913,7016,7109,7119,7130,6944,7130) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > par2 <- '1' > par1 <- '60' > #'GNU S' R Code compiled by R2WASP v. 1.2.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) in Free Statistics Software (v$_version), Office for Research Development and Education, URL http://www.wessa.net/rwasp_autocorrelation.wasp/ > #Source of accompanying publication: > # > if (par1 == 'Default') { + par1 = 10*log10(length(x)) + } else { + par1 <- as.numeric(par1) + } > par2 <- as.numeric(par2) > par3 <- as.numeric(par3) > par4 <- as.numeric(par4) > par5 <- as.numeric(par5) > if (par6 == 'White Noise') par6 <- 'white' else par6 <- 'ma' > par7 <- as.numeric(par7) > if (par8 != '') par8 <- as.numeric(par8) > ox <- x > if (par8 == '') { + if (par2 == 0) { + x <- log(x) + } else { + x <- (x ^ par2 - 1) / par2 + } + } else { + x <- log(x,base=par8) + } > if (par3 > 0) x <- diff(x,lag=1,difference=par3) > if (par4 > 0) x <- diff(x,lag=par5,difference=par4) > postscript(file="/var/wessaorg/rcomp/tmp/1d5za1408301957.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > op <- par(mfrow=c(2,1)) > plot(ox,type='l',main='Original Time Series',xlab='time',ylab='value') > if (par8=='') { + mytitle <- paste('Working Time Series (lambda=',par2,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(lambda=',par2,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } else { + mytitle <- paste('Working Time Series (base=',par8,', d=',par3,', D=',par4,')',sep='') + mysub <- paste('(base=',par8,', d=',par3,', D=',par4,', CI=', par7, ', CI type=',par6,')',sep='') + } > plot(x,type='l', main=mytitle,xlab='time',ylab='value') > par(op) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/267bn1408301957.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > racf <- acf(x, par1, main='Autocorrelation', xlab='time lag', ylab='ACF', ci.type=par6, ci=par7, sub=mysub) > dev.off() null device 1 > postscript(file="/var/wessaorg/rcomp/tmp/3qfjm1408301957.ps",horizontal=F,onefile=F,pagecentre=F,paper="special",width=8.3333333333333,height=5.5555555555556) > rpacf <- pacf(x,par1,main='Partial Autocorrelation',xlab='lags',ylab='PACF',sub=mysub) > dev.off() null device 1 > (myacf <- c(racf$acf)) [1] 1.000000000 -0.014589155 0.026432672 0.001089757 -0.087560138 [6] 0.001822387 -0.362918531 0.033195577 -0.126036403 -0.022528138 [11] -0.025961973 0.001278560 0.803742242 -0.013886492 0.014593803 [16] 0.034186626 -0.055737238 -0.021592773 -0.288251382 0.006712550 [21] -0.098683571 -0.057471463 -0.044181823 0.010877685 0.629389189 [26] 0.019970143 -0.007004629 0.054538158 -0.028722407 -0.048277376 [31] -0.225804708 -0.030182656 -0.053373228 -0.083660001 -0.038206130 [36] 0.030424983 0.470001511 0.033882705 -0.043279516 0.066447689 [41] -0.013359518 -0.070205536 -0.172511915 -0.032886258 -0.015115971 [46] -0.123375836 -0.026316486 0.044103354 0.337265035 0.029264291 [51] -0.088816628 0.064140636 -0.009414221 -0.086305976 -0.130680624 [56] -0.045840238 -0.011303122 -0.155532419 -0.005021668 0.037207149 [61] 0.243975135 > (mypacf <- c(rpacf$acf)) [1] -0.014589155 0.026225411 0.001849546 -0.088291327 -0.000752883 [6] -0.361208638 0.026692339 -0.143877447 -0.026984560 -0.110731165 [11] 0.002468735 0.769799013 0.039133131 -0.157390778 0.036001353 [16] 0.010407786 -0.012328153 0.150693488 -0.131019038 0.077770021 [21] 0.004184711 -0.009583554 0.016174489 -0.031436761 0.057334743 [26] 0.027046407 -0.078050251 0.047889277 -0.047250770 -0.011926762 [31] -0.014199114 0.032559458 0.006354544 0.050139558 0.011795566 [36] -0.065658715 -0.057494286 -0.020439491 -0.017079851 0.021867546 [41] -0.029119014 -0.007457947 0.065482818 -0.001578273 -0.098591671 [46] 0.010124893 0.005235345 -0.024910317 -0.029871611 -0.110038846 [51] -0.036566995 0.027963368 -0.033949165 -0.006465914 -0.069894490 [56] -0.086083564 -0.018061096 -0.001077307 -0.085226511 -0.001383362 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #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,'Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','ACF(k)','click here for more information about the Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 2:(par1+1)) { + a<-table.row.start(a) + a<-table.element(a,i-1,header=TRUE) + a<-table.element(a,round(myacf[i],6)) + mytstat <- myacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/4alwk1408301957.tab") > a<-table.start() > a<-table.row.start(a) > a<-table.element(a,'Partial Autocorrelation Function',4,TRUE) > a<-table.row.end(a) > a<-table.row.start(a) > a<-table.element(a,'Time lag k',header=TRUE) > a<-table.element(a,hyperlink('http://www.xycoon.com/basics.htm','PACF(k)','click here for more information about the Partial Autocorrelation Function'),header=TRUE) > a<-table.element(a,'T-STAT',header=TRUE) > a<-table.element(a,'P-value',header=TRUE) > a<-table.row.end(a) > for (i in 1:par1) { + a<-table.row.start(a) + a<-table.element(a,i,header=TRUE) + a<-table.element(a,round(mypacf[i],6)) + mytstat <- mypacf[i]*sqrtn + a<-table.element(a,round(mytstat,4)) + a<-table.element(a,round(1-pt(abs(mytstat),lengthx),6)) + a<-table.row.end(a) + } > a<-table.end(a) > table.save(a,file="/var/wessaorg/rcomp/tmp/5ree51408301957.tab") > > try(system("convert tmp/1d5za1408301957.ps tmp/1d5za1408301957.png",intern=TRUE)) character(0) > try(system("convert tmp/267bn1408301957.ps tmp/267bn1408301957.png",intern=TRUE)) character(0) > try(system("convert tmp/3qfjm1408301957.ps tmp/3qfjm1408301957.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.222 0.232 1.456