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(102.8,103.66,103.55,103.87,104.03,104.02,104.02,102.97,103.18,103.53,103.78,103.85,103.85,104.78,104.76,104.84,104.85,104.83,104.83,103.71,103.84,104.37,104.44,104.4,99.54,100.42,100.34,100.36,100.37,100.42,100.41,99.13,99.42,99.76,99.92,99.92,100.47,100.44,100.47,100.61,100.73,100.64,99.99,99.74,99.49,99.41,99.49,99.53,99.91,99.84,99.67,99.39,99.38,99.29,97.91,97.62,97.67,97.64,97.63,97.66) > 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/12bgy1476864209.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/2m1gv1476864209.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/3m3u41476864209.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.92381073 0.85477184 0.78851198 0.72873854 0.66776270 [7] 0.59469253 0.55476358 0.49928907 0.44542749 0.39929977 0.35741063 [13] 0.32544285 0.27882147 0.22748417 0.18151426 0.14399242 0.11459983 [19] 0.07528682 0.04523222 0.01644124 -0.01711648 -0.04834139 -0.07848081 [25] -0.10369784 -0.11678091 -0.13442933 -0.15573723 -0.18509638 -0.21689012 [31] -0.22779339 -0.25455615 -0.28128388 -0.30901888 -0.33647230 -0.36253808 [37] -0.40699398 -0.40038191 -0.39367913 -0.38776124 -0.38780701 -0.38897835 [43] -0.36962175 -0.34573376 -0.32010541 -0.29307826 -0.26539803 -0.23688860 [49] -0.22406186 > (mypacf <- c(rpacf$acf)) [1] 0.923810729 0.009180212 -0.016150666 0.008939957 -0.038708473 [6] -0.118198841 0.178361577 -0.126238352 -0.029857963 0.037313095 [11] -0.009354795 0.009383712 -0.061505910 -0.115094057 0.003968581 [16] 0.034563843 0.012666917 -0.066669024 0.008903450 -0.033654753 [21] -0.049602766 -0.008461145 -0.021710089 -0.046813961 0.099915768 [26] -0.045456336 -0.071372025 -0.075231412 -0.083960290 0.104365001 [31] -0.096563010 -0.079093807 -0.030703725 -0.055581840 -0.051175556 [36] -0.123535317 0.243035144 -0.029111025 -0.020318248 -0.020657751 [41] -0.029945388 0.002375365 0.177036116 -0.065394441 0.019749930 [46] 0.036347938 -0.042164337 -0.046188584 > 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/4w8aw1476864209.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/5xctn1476864209.tab") > > try(system("convert tmp/12bgy1476864209.ps tmp/12bgy1476864209.png",intern=TRUE)) character(0) > try(system("convert tmp/2m1gv1476864209.ps tmp/2m1gv1476864209.png",intern=TRUE)) character(0) > try(system("convert tmp/3m3u41476864209.ps tmp/3m3u41476864209.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.162 0.052 1.231