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(96.07,95,93.27,91.94,91.62,91.01,90.62,97.72,99.09,99.72,100.22,99.15,101.16,101.8,103.31,101.19,99.09,95.91,94.56,95.76,100.36,102.67,103.58,100.89,103.46,104.86,104.88,104.46,103.83,101,99.36,96.71,95.23,95.62,95.8,94.79,95.39,94.9,94.84,94.68,94.17,94.1,93.84,94.2,97.76,98.26,99.63,98.75,100.15,99.63,99.72,98.87,98.4,97.99,98.46,98.73,98.66,98.14,98.39,97.78) > 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/1ugdx1476879025.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/2tza01476879025.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/3ugwj1476879025.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.0000000000 0.8778943504 0.6850666043 0.4635098117 0.2806948792 [6] 0.1345626127 0.0098471631 -0.1180752024 -0.2122434165 -0.2742863145 [11] -0.2646471589 -0.2044444698 -0.1186327703 -0.0747889820 -0.0831914041 [16] -0.1343960675 -0.1891902586 -0.2265409526 -0.2699060015 -0.3076898462 [21] -0.3220556416 -0.3294658630 -0.3108300531 -0.2672073175 -0.2117084993 [26] -0.1635978042 -0.1078291194 -0.0677916441 -0.0217435933 0.0268116246 [31] 0.0670822852 0.0963319288 0.1284780589 0.1524354547 0.1896698039 [36] 0.2088513054 0.2231735852 0.2147342434 0.1769707141 0.1347843256 [41] 0.0889628869 0.0484259556 0.0007973935 -0.0361479218 -0.0602993266 [46] -0.0638368408 -0.0564201862 -0.0437076407 -0.0361405154 > (mypacf <- c(rpacf$acf)) [1] 0.8778943504 -0.3734466746 -0.1756332682 0.0897920873 -0.0530375011 [6] -0.1340932965 -0.1719037478 0.0724706235 -0.0268611054 0.1342784411 [11] 0.0587772560 0.0020982674 -0.2088367194 -0.1563477400 -0.0842618088 [16] -0.0615454527 -0.0148847305 -0.1903331144 0.0280122019 0.1043292539 [21] -0.1145925078 -0.0709070279 -0.0363289020 -0.1053344657 -0.1809255240 [26] 0.1004183321 -0.0566031604 0.0004554669 0.0382086322 -0.0130691858 [31] -0.0011917602 0.0191890919 -0.0459905314 -0.0018872981 -0.0551288210 [36] 0.0177437490 -0.0621987328 -0.1010148156 0.0762101671 -0.1140300781 [41] -0.0250058836 -0.0931915034 0.0148750592 -0.0134921228 0.0097912848 [46] -0.0989866518 -0.0429678372 -0.0038480472 > 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/4dc3m1476879025.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/5bvut1476879025.tab") > > try(system("convert tmp/1ugdx1476879025.ps tmp/1ugdx1476879025.png",intern=TRUE)) character(0) > try(system("convert tmp/2tza01476879025.ps tmp/2tza01476879025.png",intern=TRUE)) character(0) > try(system("convert tmp/3ugwj1476879025.ps tmp/3ugwj1476879025.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.149 0.069 1.236