R version 3.2.2 (2015-08-14) -- "Fire Safety" 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(104.37,104.66,104.88,105.08,104.53,104.97,105.73,106.11,106.16,106.53,107.23,107.56,106.46,107.42,107.84,108.65,107.58,107.67,107.09,106.96,107.63,108.03,107.33,107.16,106.28,107.26,106.48,106.82,106.9,106.6,106.79,107.19,106.34,106.91,106.55,106.73,106.36,107.07,106.96,107.82,108.07,108.11,108.16,108.29,108.5,108.69,109.12,108.82,108.07,109.92,109.24,109.9,109.7,110.15,109.73,109.62,110.42,110.69,110.75,111.41,110.56,110.88,111.35,110.31,111.63,111.24,111.66,111.44,110.72,111.19,110.07,110.86,110.46,111,111.11,111.9,111.38,111.69,111.65,111.98,111.63,112.57,112.38,111.73) > 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.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) 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) > 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/1myy31446230086.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/2irv71446230086.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/3tg0p1446230086.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.928829494 0.888319347 0.833114041 0.795622883 [6] 0.744190906 0.698596343 0.656322717 0.617719097 0.566109094 [11] 0.539918451 0.504053401 0.493033916 0.457379637 0.438169779 [16] 0.418292386 0.407412541 0.376513124 0.354312788 0.319234162 [21] 0.289660693 0.260586892 0.248920575 0.218127290 0.200983058 [26] 0.156171968 0.131195804 0.089529188 0.068826455 0.046799948 [31] 0.018861723 -0.009643198 -0.032121061 -0.072960456 -0.092021915 [36] -0.127830660 -0.140549147 -0.182097051 -0.207799020 -0.238794387 [41] -0.260756793 -0.275332322 -0.288328079 -0.305540643 -0.317485698 [46] -0.338687898 -0.340320662 -0.346518750 -0.346170904 > (mypacf <- c(rpacf$acf)) [1] 0.9288294941 0.1864503635 -0.0854625415 0.0698759898 -0.0768853814 [6] -0.0299559457 0.0270531250 0.0001152239 -0.1111486931 0.1342975915 [11] -0.0209327418 0.1171630729 -0.0962717744 0.0117311266 0.0491579720 [16] 0.0297950839 -0.1226768629 -0.0100070354 -0.0781569889 -0.0530070365 [21] 0.0805475468 0.0714658573 -0.1070388144 0.0287483748 -0.1532902083 [26] -0.0007966439 -0.0616912457 0.0239790961 0.0616431408 -0.1082195881 [31] -0.0145695674 0.0161449873 -0.1577502871 0.0310379131 -0.0091595661 [36] 0.0069935560 -0.1321416628 -0.0270745696 -0.0236125463 -0.0232460143 [41] 0.1117383360 0.0006137824 -0.0207796919 -0.0841320413 -0.0430166638 [46] 0.0410984946 0.0331722193 -0.0348781012 > 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/4ptq01446230086.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/5rcmn1446230086.tab") > > try(system("convert tmp/1myy31446230086.ps tmp/1myy31446230086.png",intern=TRUE)) character(0) > try(system("convert tmp/2irv71446230086.ps tmp/2irv71446230086.png",intern=TRUE)) character(0) > try(system("convert tmp/3tg0p1446230086.ps tmp/3tg0p1446230086.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.252 0.219 1.482