R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(19.4,19.4,19.4,19.5,19.5,19.5,28.7,28.7,28.7,21.8,21.8,21.8,20,20,20,22.6,22.6,22.6,22.4,22.4,22.4,18.6,18.6,18.6,16.2,16.2,16.2,13.8,13.8,13.8,24.1,24.1,24.1,19.9,19.9,19.9,22.3,22.3,22.3,20.9,20.9,20.9,23.5,23.5,23.5,23.1,23.1,23.1,25.7,25.7,25.7,19.7,19.7,19.7,23.1,23.1,23.1,20.7,20.7,20.7,18,18,18,16.9,16.9,16.9,24.4,24.4,24.4,15.5,15.5,15.5,18.4,18.4,18.4,16.2,16.2,16.2,20.6,20.6,20.6,19.8,19.8,19.8) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '48' > #'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/12d6l1384333262.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/2cmf51384333262.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/3kkwp1384333262.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.692713306 0.385426611 0.078139917 0.089103764 [6] 0.100067610 0.111031457 0.063954498 0.016877540 -0.030199419 [11] 0.033158937 0.096517292 0.159875648 0.028926943 -0.102021762 [16] -0.232970466 -0.208942372 -0.184914278 -0.160886184 -0.254090512 [21] -0.347294840 -0.440499168 -0.273369913 -0.106240658 0.060888596 [26] -0.026736184 -0.114360965 -0.201985745 -0.139699390 -0.077413034 [31] -0.015126679 -0.029418769 -0.043710860 -0.058002950 0.040389624 [36] 0.138782198 0.237174772 0.156053567 0.074932361 -0.006188845 [41] 0.050481774 0.107152393 0.163823011 0.095802242 0.027781473 [46] -0.040239296 0.047836986 0.135913268 0.223989550 > (mypacf <- c(rpacf$acf)) [1] 0.6927133057 -0.1815349907 -0.2217993301 0.3804165805 -0.0995519681 [6] -0.1105582605 0.1425743645 -0.0829665794 -0.0904727980 0.2859601003 [11] -0.0502357636 -0.0528928777 -0.1398088463 -0.0700864798 -0.0753688147 [16] -0.0102593811 -0.0769313199 -0.0833430074 -0.2039951549 -0.1260602592 [21] -0.1442436513 0.3196167983 -0.0743708002 -0.0803462124 0.0347994507 [26] -0.0749422589 -0.0810136011 0.1426565395 -0.0607850905 -0.0647190434 [31] 0.1338108977 -0.0494429276 -0.0520146859 0.1226164910 -0.0406521978 [36] -0.0423748277 -0.0003674814 -0.0424059830 -0.0442838847 0.0348189329 [41] -0.0413038124 -0.0430833177 0.0500732211 -0.0389744223 -0.0405550313 [46] 0.1411423908 -0.0305229194 -0.0314838999 > 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/43aga1384333262.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/5och81384333262.tab") > > try(system("convert tmp/12d6l1384333262.ps tmp/12d6l1384333262.png",intern=TRUE)) character(0) > try(system("convert tmp/2cmf51384333262.ps tmp/2cmf51384333262.png",intern=TRUE)) character(0) > try(system("convert tmp/3kkwp1384333262.ps tmp/3kkwp1384333262.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.922 0.401 2.302