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(109.12,109.12,109.73,112.59,112.59,112.29,113.8,114.16,112.29,112.29,110.99,110.99,110.99,110.99,111.98,114.26,114.26,114.44,115.47,115.41,114.63,116.48,115.8,115.18,115.18,115.18,115.18,116.38,122.41,122.47,123.09,123.09,123.09,123.09,121.77,121.52,121.52,121.52,121.52,124.73,125.23,124.62,128.94,129.34,127.17,128.08,124.54,121.21,120.85,119.02,119.13,119.84,125.53,124.16,127.32,127.22,122.57,125.45,125.45,127.32,128.79,128.99,129.8,130.33,131.19,132.02,136.97,139.45,128.31,130.73,129.83,125.46,130.23,130.23,132.65,136.34,139.12,133.94,143.09,142.71,136.09,134.57,134.65,134.35) > 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/1r8961457949911.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/2zm2u1457949911.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/3ul651457949911.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.00000000 -0.16552269 -0.12639026 0.25842006 -0.22185375 -0.21272230 [7] 0.02710938 -0.12037316 -0.20143400 0.24643477 -0.12071882 -0.10896788 [13] 0.41288609 0.01631765 -0.07823736 0.18055965 -0.20315764 -0.07317914 [19] -0.02894118 -0.11371996 -0.10457397 0.14441407 0.02786658 -0.08008242 [25] 0.34253639 -0.04713051 -0.05842904 0.09701438 -0.16632296 -0.18149435 [31] 0.04939574 -0.03001934 -0.10359137 0.14644728 0.05019656 -0.04401260 [37] 0.19331924 0.03968027 -0.04508257 0.12482663 -0.13132419 -0.08686863 [43] -0.02174914 -0.06089589 -0.02637703 0.05131369 0.05821560 -0.01384097 [49] 0.10353363 > (mypacf <- c(rpacf$acf)) [1] -0.165522691 -0.158120160 0.219363516 -0.176856096 -0.238680423 [6] -0.162124426 -0.129367253 -0.261496341 0.074265839 -0.214762752 [11] -0.202677073 0.145653069 0.114322788 0.005671957 -0.003514385 [16] -0.228212889 0.053559261 -0.138670077 -0.022446862 -0.140147746 [21] -0.047901353 -0.006198994 -0.019366549 0.135125578 -0.028539103 [26] -0.097384675 -0.068857668 -0.084497561 -0.186938422 -0.069400224 [31] -0.029549012 -0.047038701 -0.070970466 -0.083391476 -0.060327749 [36] -0.097690919 -0.063300035 -0.005597355 0.002567730 -0.039221800 [41] 0.047967114 -0.000150453 -0.020566125 0.020663989 -0.047592328 [46] 0.018494628 -0.012238092 -0.044003931 > 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/41aay1457949911.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/5s0ph1457949911.tab") > > try(system("convert tmp/1r8961457949911.ps tmp/1r8961457949911.png",intern=TRUE)) character(0) > try(system("convert tmp/2zm2u1457949911.ps tmp/2zm2u1457949911.png",intern=TRUE)) character(0) > try(system("convert tmp/3ul651457949911.ps tmp/3ul651457949911.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.175 0.232 1.411