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.77,97.63,100.87,100.39,98.62,97.42,95.62,97.22,97.56,97.06,97.68,98.18,98.54,98.24,98.1,96.32,96.15,96.67,94.7,93.94,96.69,96.54,95.94,95.6,99.15,100.33,99.86,96.09,94.42,93.85,93.73,94.63,95.54,95.48,95.84,96.29,97.63,98.8,99.84,100.73,100.44,100.54,100.25,100.29,100.7,100.62,100.43,99.73,99.17,98.9,98.94,98.91,99.5,99.52,99.1,99.12,99,98.66,98.3,98.18,97.95,97.84,98.61,99.54,99.64,99.69,99.77,99.85,99.87,100.23,100.46,100.36) > 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/1n8ar1476873765.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/28b4d1476873765.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/3r1br1476873765.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.826671655 0.581201252 0.424971620 0.338337474 [6] 0.261377383 0.190567160 0.120207729 0.098276975 0.097396033 [11] 0.104633156 0.129808278 0.173986561 0.170014063 0.127251341 [16] 0.069145252 -0.006396414 -0.030841569 -0.028506657 -0.059529848 [21] -0.094050797 -0.048078963 0.006663300 0.009149257 -0.042615792 [26] -0.092821482 -0.095425091 -0.059496484 -0.046304809 -0.044805738 [31] -0.065421809 -0.107900826 -0.154466891 -0.199971719 -0.228586649 [36] -0.241166489 -0.238672826 -0.219245719 -0.196459957 -0.175242954 [41] -0.157915291 -0.124730060 -0.081040215 -0.059827736 -0.060195927 [46] -0.069464452 -0.109134663 -0.141713995 -0.150262783 > (mypacf <- c(rpacf$acf)) [1] 0.8266716554 -0.3227424629 0.1983022513 -0.0142471329 -0.0428820517 [6] 0.0110313506 -0.0681685957 0.1356641338 -0.0477987862 0.0723761903 [11] 0.0824839868 0.0639353846 -0.1135844763 -0.0129301850 -0.0638899262 [16] -0.1328290206 0.1718017502 -0.0954958057 -0.0524640437 0.0229000554 [21] 0.1999474698 -0.1135848316 -0.0927468572 -0.0837435424 -0.0244235784 [26] 0.0749933681 0.0178104562 0.0583127852 -0.0197355791 -0.1124611631 [31] -0.0492660074 -0.0812764647 -0.1525079035 0.0266642557 -0.0523402541 [36] 0.0222275221 0.1506741280 -0.0423779790 -0.0617174123 -0.0945601352 [41] 0.0923230543 0.0006427819 -0.0367381167 -0.0152610712 0.0663077386 [46] -0.1086374086 0.0596578678 -0.0169448126 > 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/4x7zr1476873765.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/59wdl1476873765.tab") > > try(system("convert tmp/1n8ar1476873765.ps tmp/1n8ar1476873765.png",intern=TRUE)) character(0) > try(system("convert tmp/28b4d1476873765.ps tmp/28b4d1476873765.png",intern=TRUE)) character(0) > try(system("convert tmp/3r1br1476873765.ps tmp/3r1br1476873765.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.096 0.066 1.173