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(89.65,90.65,89.34,89.15,88.82,88.82,91.97,93.01,93.24,93.2,93.19,92.2,93.39,94.75,94.25,94.37,94.02,92.77,92.64,93.19,92.74,92.52,92.25,91.6,93.73,96.21,96.36,95.69,95.07,95.5,95.22,97.41,98.31,98.54,98.45,98.03,101.45,102.44,102.42,100.98,100.69,100.28,98.06,97.37,97.25,98.93,100.04,100.09,100.79,99.76,99.63,99.26,99.69,99.17,98.79,97.97,98.1,97.91,97.16,96.8,97.46,96.59,96.35,96.12,96.16,95.95,96.06,95.89,95.9,95.82,95.54,95.51) > 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/1lh771457982329.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/2f9lw1457982329.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/33zh91457982329.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.931993127 0.853553151 0.771426891 0.701967788 [6] 0.642918086 0.580600595 0.537163657 0.491635828 0.458117069 [11] 0.424206459 0.400731367 0.369200457 0.317275369 0.277418667 [16] 0.239349669 0.206877210 0.172189521 0.136772332 0.099863463 [21] 0.057453772 0.009984504 -0.042697761 -0.088850168 -0.145178883 [26] -0.195421009 -0.229436981 -0.263355449 -0.298876738 -0.339743706 [31] -0.367718700 -0.402885035 -0.423724757 -0.437496316 -0.444535462 [36] -0.439518662 -0.439381682 -0.404530825 -0.357352545 -0.312512353 [41] -0.287921620 -0.274340607 -0.264339654 -0.270752800 -0.273799106 [46] -0.278736104 -0.269037037 -0.248284767 -0.230925730 > (mypacf <- c(rpacf$acf)) [1] 0.931993127 -0.114606702 -0.065064041 0.055213600 0.026202230 [6] -0.078457250 0.116248681 -0.055142198 0.053911211 -0.021247639 [11] 0.068058941 -0.100716486 -0.146292640 0.091910099 -0.004213247 [16] -0.044705369 -0.012976642 -0.027770756 -0.072403232 -0.052455717 [21] -0.085447978 -0.074012805 -0.020151534 -0.111256480 -0.003739895 [26] 0.042437319 -0.093107825 -0.090510314 -0.057439881 0.031261956 [31] -0.138922400 0.079414413 0.026104785 -0.026891807 0.039858647 [36] 0.009865247 0.205549521 0.091255185 -0.004489879 -0.067159488 [41] 0.001522344 -0.032695119 -0.083956651 -0.016494524 0.005486391 [46] 0.033572615 0.083579938 -0.052325753 > 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/4l4jb1457982329.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/5jp2v1457982329.tab") > > try(system("convert tmp/1lh771457982329.ps tmp/1lh771457982329.png",intern=TRUE)) character(0) > try(system("convert tmp/2f9lw1457982329.ps tmp/2f9lw1457982329.png",intern=TRUE)) character(0) > try(system("convert tmp/33zh91457982329.ps tmp/33zh91457982329.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.276 0.242 1.524