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(103.1,95.2,110.2,105.3,107.4,108.1,108,98.8,104.2,107.8,103.5,129.6,100.1,96,111.4,108.3,103.6,106.8,102.5,101,105.5,105.1,103.9,126.4,101,99.3,113.5,99.1,108.2,109.2,100.1,105.5,103,105.8,106.1,122.2,101.9,94.5,112.1,97.6,110,104.6,102.1,106,98.5,106.2,106,120.9,105.1,102.4,94.2,105.6,102.9,111.4,105.4,104.6,103.6,102.1,109.3,103.9,125.3,105.9,106.2,96.2,105.5,104.7,111,109.2,108.3,106.7,103.6,103.9,104.7,112.4,103.2,129.1,114.9,107.6,102.8,99.1,111.9,104.6,103.7,108.5,110.1,107.5,106.8) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1z4y31476789481.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/2sxo41476789481.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/3x2911476789481.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.524030321 0.027303257 0.063921098 -0.173186229 [6] 0.047975119 0.084640014 0.027391402 -0.139455609 0.291528980 [11] -0.313553372 -0.056093600 0.279250594 -0.059608224 -0.175563255 [16] 0.313570318 -0.326217547 0.130883458 0.052193431 -0.126329793 [21] 0.147888916 -0.060573724 -0.005900462 -0.142923347 0.253352267 [26] -0.122934363 0.003031809 0.033349605 -0.102289122 0.100542143 [31] -0.012352651 -0.043432807 0.059544672 -0.002646123 -0.058042636 [36] 0.003906578 -0.020094766 0.093358654 0.015998784 -0.129522941 [41] 0.079992134 -0.044254354 0.040073613 0.007993282 -0.036946652 [46] 0.051454578 -0.048772212 0.059280075 -0.173609639 > (mypacf <- c(rpacf$acf)) [1] -0.5240303213 -0.3409252437 -0.1490429952 -0.3046348361 -0.3561313102 [6] -0.2597440089 -0.0959928546 -0.3007574636 0.1110309194 -0.0337101946 [11] -0.3774577014 -0.1967978736 0.1641440976 -0.2770808492 0.0164745280 [16] -0.1072377076 0.0141803885 -0.0761888152 -0.0238010059 0.1749060070 [21] -0.0576909119 -0.0929713282 0.0347023208 -0.0481996060 0.0449606027 [26] 0.1119740537 -0.0731699565 -0.1268642861 0.0542457081 0.0173328103 [31] -0.0213253088 -0.0550981027 0.0008446399 0.0151609020 -0.0504252826 [36] -0.0557661792 -0.0936039570 0.1056538503 -0.1497105422 -0.0447271948 [41] -0.0716247059 -0.0271357295 0.0389411219 -0.1417897926 0.0067951001 [46] -0.0353412596 0.0779156775 -0.0582489672 > 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/47j1t1476789481.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/5zorw1476789481.tab") > > try(system("convert tmp/1z4y31476789481.ps tmp/1z4y31476789481.png",intern=TRUE)) character(0) > try(system("convert tmp/2sxo41476789481.ps tmp/2sxo41476789481.png",intern=TRUE)) character(0) > try(system("convert tmp/3x2911476789481.ps tmp/3x2911476789481.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.445 0.079 1.559