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(97.78,97.73,97.61,97.69,97.68,97.67,97.67,97.96,98.27,99.52,99.59,99.75,99.75,99.8,99.99,100.25,100.08,100.08,100.08,100.06,101,101.81,101.82,101.96,101.96,101.93,102.03,102.11,102.07,102.34,102.34,102.33,102.77,103.08,103.38,103.44,99.1,99.15,99.21,99.01,99.08,99.11,100.11,100.31,100.55,101.38,101.49,101.5,100.69,100.8,100.58,100.34,100.38,100.33,101.06,101.15,101.36,101.98,102.24,102.34) > 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/1tvvz1457435470.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/2i4od1457435470.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/3r61z1457435470.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.877760006 0.743186905 0.608410045 0.479386895 [6] 0.366822490 0.253546011 0.183386515 0.132191519 0.091353077 [11] 0.089891242 0.087941924 0.074134580 0.002289040 -0.075072342 [16] -0.161481887 -0.221093496 -0.254258903 -0.289750893 -0.291929431 [21] -0.290481539 -0.275910022 -0.231877117 -0.185186551 -0.140389882 [26] -0.159856511 -0.186893639 -0.208944609 -0.188757495 -0.153511679 [31] -0.106134840 -0.056714717 -0.006760006 0.048271325 0.101132270 [36] 0.147394628 0.186527130 0.137208551 0.083235636 0.027743940 [41] -0.016909598 -0.047779238 -0.074765530 -0.083027510 -0.088463746 [46] -0.091763180 -0.083155700 -0.073908984 -0.067806253 > (mypacf <- c(rpacf$acf)) [1] 0.8777600063 -0.1188291176 -0.0757556025 -0.0582972510 -0.0161052834 [6] -0.0929410170 0.1032787968 0.0012343387 -0.0173967536 0.1228552019 [11] -0.0278115916 -0.0829043419 -0.2623017973 -0.0429700179 -0.1247401875 [16] 0.0892919409 0.0457938355 -0.0677711683 0.0447155441 -0.0625140724 [21] -0.0272459962 0.0398364199 0.0429469629 -0.0183611377 -0.1946243351 [26] -0.0063328301 -0.0189457052 0.1884639617 0.0242439722 0.0931160350 [31] -0.0750752638 0.0295389622 -0.0056963934 -0.0310337822 0.0384533732 [36] 0.0310986247 -0.2397878028 0.0146264734 0.0001166069 -0.0748692366 [41] -0.0314538402 0.0119889107 -0.0359740685 -0.0119904778 -0.0023044503 [46] -0.0709881581 -0.0333494592 0.0403015073 > 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/4d7ov1457435470.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/5qt951457435470.tab") > > try(system("convert tmp/1tvvz1457435470.ps tmp/1tvvz1457435470.png",intern=TRUE)) character(0) > try(system("convert tmp/2i4od1457435470.ps tmp/2i4od1457435470.png",intern=TRUE)) character(0) > try(system("convert tmp/3r61z1457435470.ps tmp/3r61z1457435470.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.175 0.189 1.373