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(134.93,134.37,132.98,130.1,128.24,127.52,126.94,127.38,130.95,128.65,127.37,127.04,125.95,124.06,121.55,119.82,119.19,118.77,118.31,119.47,119.79,117.46,115.74,114.97,112.83,111.44,110.6,109.67,107.96,107.56,116.12,114.38,113.96,113.95,114.99,113.64,112.53,110.59,110.1,109.38,110.43,114.67,114.48,114.76,113.27,111.56,109.89,108.04,107.53,106.11,104.11,103,104.74,104.14,101.98,100.91,100.02,98.49,97.38,95.86,93.99,94.09,93.44,93.61,98.31,103.97,104.12,107.63,105.22,104.59,101.54,99.47) > 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/12ur11476871449.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/2qa8p1476871449.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/3k0ny1476871449.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.213985366 0.094451293 0.015810717 -0.082544625 [6] -0.260510732 -0.237685754 -0.121875122 -0.066756636 -0.056036225 [11] 0.061221076 0.298857164 0.117177514 0.026666122 -0.056889109 [16] -0.091902428 -0.205931112 -0.192971413 -0.087995213 -0.100240014 [21] -0.146936973 -0.029487871 0.318215091 0.182987235 0.134371688 [26] 0.048762343 0.031018220 -0.185878208 -0.140243036 -0.116048470 [31] -0.104717058 0.024621256 0.045931234 0.178247838 0.204630840 [36] 0.248596692 -0.009827653 0.048588056 -0.146285344 -0.083926269 [41] -0.124539955 -0.076999072 -0.026945793 -0.061110686 0.056468296 [46] 0.085764614 0.049582163 0.055167782 0.028794479 > (mypacf <- c(rpacf$acf)) [1] 0.213985366 0.050996681 -0.015006710 -0.092127642 -0.238886458 [6] -0.146989340 -0.022564872 -0.015914818 -0.064373192 0.010268613 [11] 0.234655869 -0.028282391 -0.076239292 -0.124284096 -0.066838733 [16] -0.077604346 -0.062535217 -0.017505230 -0.109626252 -0.180553824 [21] -0.102631463 0.239946870 0.049969755 -0.007491616 -0.103727564 [26] -0.023732318 -0.104002252 0.008639218 -0.060042114 -0.076406984 [31] 0.157139492 0.029336027 -0.049038852 0.008588032 0.145577949 [36] -0.122140479 0.076282995 -0.027420947 0.075047619 -0.035768100 [41] 0.002220608 0.056365930 -0.038114864 -0.017673106 -0.036340108 [46] -0.098297228 0.079627228 0.000365323 > 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/4zxh21476871449.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/5i7co1476871449.tab") > > try(system("convert tmp/12ur11476871449.ps tmp/12ur11476871449.png",intern=TRUE)) character(0) > try(system("convert tmp/2qa8p1476871449.ps tmp/2qa8p1476871449.png",intern=TRUE)) character(0) > try(system("convert tmp/3k0ny1476871449.ps tmp/3k0ny1476871449.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.162 0.068 1.255