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(28886,28549,33348,29017,30924,30435,29431,30290,31286,30622,31742,30391,30740,32086,33947,31312,33239,32362,32170,32665,31412,34891,33919,30706,32846,31368,33130,31665,33139,32201,32230,30287,31918,33853,32232,31484,31902,30260,32823,32018,32100,31952,33274,29491,32751,33643,31226,30976,28880,29325,34923,32642,31487,33832,32724,29545,32338,32743,32231,32536) > 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/1c0u01476815083.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/2ylp21476815083.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/3j6qr1476815083.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.092486567 0.007187314 0.205596285 0.035764543 [6] 0.123503827 0.291450224 0.032432480 0.121056534 -0.005625206 [11] -0.217661120 -0.005637475 0.276077015 -0.230136617 -0.054419011 [16] -0.193580464 -0.136963822 0.020750255 -0.053125191 -0.063678761 [21] 0.013852288 -0.211810883 -0.145172564 -0.020990060 0.091463266 [26] -0.030403739 -0.017514810 -0.225072272 0.020836960 -0.002949353 [31] -0.033302450 0.098409832 0.022587935 -0.134602280 -0.029297698 [36] -0.049203981 0.105998157 0.130127593 -0.026926070 -0.063494576 [41] 0.115852548 -0.099929162 0.046335352 0.131043415 -0.069411385 [46] -0.020061830 0.004620764 -0.063774870 0.111547714 > (mypacf <- c(rpacf$acf)) [1] 0.092486567 -0.001378241 0.206827652 -0.002440765 0.129746300 [6] 0.242814700 -0.009746571 0.101535989 -0.135545065 -0.259788123 [11] -0.102488646 0.250294774 -0.263390732 -0.021355823 -0.273274619 [16] 0.126492043 0.038064790 0.007907464 0.066033584 -0.038184573 [21] -0.011977019 -0.013711247 -0.053957098 0.024856035 0.023369914 [26] -0.062850884 -0.113984125 -0.007574450 -0.028466610 0.007688886 [31] 0.031480609 0.025541854 -0.021714061 -0.027212165 -0.018556119 [36] 0.003144664 0.105740779 -0.043745071 0.072050461 0.004684954 [41] -0.097757590 -0.024232540 -0.023321194 -0.102527802 -0.006026669 [46] 0.010170102 0.055285246 -0.017366135 > 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/4b7q51476815083.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/50ke81476815083.tab") > > try(system("convert tmp/1c0u01476815083.ps tmp/1c0u01476815083.png",intern=TRUE)) character(0) > try(system("convert tmp/2ylp21476815083.ps tmp/2ylp21476815083.png",intern=TRUE)) character(0) > try(system("convert tmp/3j6qr1476815083.ps tmp/3j6qr1476815083.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.212 0.088 1.330