R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 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(95.9,89.2,100.2,102.3,102.2,100.5,104.1,94.9,97.3,100.3,98,115.1,94.4,91.6,104.1,107.8,101.7,104.1,102,99.9,101.6,101.3,101,115.9,97.5,97.6,109.2,101.6,108.8,108.8,100.9,107.4,101.7,104.5,106.1,116.7,103.7,96.5,114.1,102.8,114.5,107.2,107.9,111.3,99.8,106.7,106.9,115.3,106.1,97.3,109,109.8,116.5,108.3,110.8,108.7,104,111.3,106.5,120.5,110,99.7,109,112.2,116,112.3,113.2,109.9,107.6,114.9,105.7,123.3) > 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.327 (Mon, 30 Nov 2015 06:58:35 +0000) > #Author: root > #To cite this work: Wessa P., (2015), (Partial) Autocorrelation Function (v1.0.12) 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) > x <- na.omit(x) > 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/1nyz91476885095.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/2fkka1476885095.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/338kg1476885095.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.207969291 0.178401576 0.240096284 0.190104332 [6] 0.429203816 0.280069756 0.371684191 0.195436801 0.192981182 [11] -0.010268453 0.123026982 0.648138603 0.083613234 0.069089993 [16] 0.046673859 0.027076343 0.281481847 0.076877458 0.185758455 [21] 0.076808204 0.007409192 -0.116456797 -0.008408203 0.321423577 [26] 0.019298068 -0.068857783 -0.093437745 -0.054905292 0.090931484 [31] -0.059537827 0.076096828 -0.057938202 -0.105045625 -0.172536924 [36] -0.155438108 0.153244909 -0.034477522 -0.185870698 -0.179879475 [41] -0.128514513 -0.077098452 -0.102461199 -0.047075178 -0.128300755 [46] -0.151407596 -0.195064694 -0.231510842 0.059241938 > (mypacf <- c(rpacf$acf)) [1] 0.2079692907 0.1412600191 0.1907493273 0.1050324560 0.3671982006 [6] 0.1475933269 0.2934339086 0.0047525582 0.0526739569 -0.4086171108 [11] -0.1609094161 0.5260537653 -0.1376913808 -0.2243638189 -0.0513660080 [16] 0.0188583648 0.0695820873 -0.1047685661 0.0068768070 -0.0263212655 [21] -0.1076282738 0.0917376211 -0.0004991399 -0.1797120380 0.0986076697 [26] -0.0482666674 0.0471867195 0.0502237257 -0.1030572965 -0.0290976243 [31] 0.0818119211 -0.1044992247 -0.0261024832 -0.0830501312 -0.0655934061 [36] 0.0562783974 0.0274401894 -0.0425974136 -0.0779969559 -0.0144095958 [41] 0.0368065197 0.0177501936 -0.0945166777 0.0317892952 -0.0572841568 [46] 0.1140683183 -0.0066152702 -0.1112859155 > 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/4hwz21476885095.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/5t29s1476885095.tab") > > try(system("convert tmp/1nyz91476885095.ps tmp/1nyz91476885095.png",intern=TRUE)) character(0) > try(system("convert tmp/2fkka1476885095.ps tmp/2fkka1476885095.png",intern=TRUE)) character(0) > try(system("convert tmp/338kg1476885095.ps tmp/338kg1476885095.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.205 0.082 1.308