R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" Copyright (C) 2015 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(45564.6,47295.5,46465.5,50679.5,47452.8,49415.4,48165.3,51814,49030.7,50820.8,49729.5,53501.6,50524.9,52095,51290.3,55064,52505.2,54318.3,53039.6,57607.6,54236.4,56586.4,55614,60085.9,56963.5,59152.8,57804.6,62541.5,59449.3,61704.7,60399,65724.7,62679.4,65526.5,64274.8,68769.1,63542.8,66198,64544.9,71041.8,66087.2,69005.8,66897,73702,68485.3,71457,69774.6,76479.7,71204.7,73783.9,71651,78541.6,72714.4,75258,73168.1,79701.6,73944.5,76401.2,73948.1,80583.3) > 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/1eye51457982314.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/25y2t1457982314.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/36e531457982314.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.0000000 -0.8170760 0.6694858 -0.8116124 0.9133598 -0.7504414 [7] 0.6167225 -0.7460047 0.8368811 -0.6845057 0.5617872 -0.6788812 [13] 0.7584380 -0.6198154 0.5155939 -0.6155257 0.6844490 -0.5564999 [19] 0.4592341 -0.5446694 0.5995791 -0.4846425 0.4034344 -0.4770585 [25] 0.5177267 -0.4329371 0.3547830 -0.4134298 0.4675408 -0.3803951 [31] 0.3115603 -0.3647302 0.4109318 -0.3338933 0.2698738 -0.3214114 [37] 0.3509289 -0.2794702 0.2289134 -0.2650046 0.2846767 -0.2219553 [43] 0.1767415 -0.2051438 0.2200930 -0.1695279 0.1386515 -0.1605115 [49] 0.1620135 > (mypacf <- c(rpacf$acf)) [1] -0.817076018 0.005633738 -0.791483180 0.302919706 0.190509845 [6] -0.340098498 -0.080891228 0.127530981 -0.082842993 -0.176985311 [11] 0.031545374 -0.031706586 -0.150628075 0.005487975 0.057420533 [16] -0.096158975 0.008838812 -0.002474321 0.009355408 -0.081989589 [21] 0.006752040 0.064977296 -0.027122854 -0.066879061 -0.134127766 [26] -0.128214937 -0.109019405 0.031479137 0.071744528 -0.019185752 [31] 0.022086604 0.046375575 0.014347909 0.010771968 -0.006102758 [36] -0.134850628 -0.005334830 0.048045210 0.066820027 -0.025488060 [41] 0.094967694 0.017742310 -0.004879296 0.050056939 0.002468708 [46] 0.087490374 0.055638104 -0.067883995 > 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/4p5091457982314.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/57gpi1457982314.tab") > > try(system("convert tmp/1eye51457982314.ps tmp/1eye51457982314.png",intern=TRUE)) character(0) > try(system("convert tmp/25y2t1457982314.ps tmp/25y2t1457982314.png",intern=TRUE)) character(0) > try(system("convert tmp/36e531457982314.ps tmp/36e531457982314.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.082 0.238 1.333