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(99.1,98.9,98.8,98.8,99.2,99.6,100.5,100.6,100.7,101,101.3,101.5,102.3,103,102.9,103.5,103.8,103.6,103.4,103.4,103.3,103.2,103.2,103.5,104.5,105.7,106.5,107,106.7,107.1,106.1,106.2,106.5,106.8,107,107.2,107.8,107.9,107.9,108.2,108.9,109.1,109.3,109.8,109.8,109.9,109.9,109.9,108.8,108.5,108.8,108.8,108.8,108.9,108.8,108.4,107.7,107.3,107,107.7) > 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/1ztf81452539234.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/2zdqn1452539234.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/3pykw1452539234.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.376438488 0.184497713 0.029299894 -0.086897458 [6] -0.247762411 -0.139796600 0.083224482 0.023823019 0.120501271 [11] 0.100863159 0.028679507 -0.003009049 -0.002936745 0.048887077 [16] -0.095256718 0.040920210 -0.002943342 0.114519589 0.110652924 [21] 0.075399056 -0.017569276 -0.227118644 -0.184215887 -0.218021834 [26] -0.044152239 0.062817153 0.166190095 0.133006911 -0.065254897 [31] 0.003383497 -0.124148122 -0.155494159 -0.114584240 0.075056801 [36] 0.031224387 -0.031057350 0.040321197 0.008975161 -0.035308755 [41] -0.037493964 -0.065243550 -0.173749792 -0.134023121 -0.073169251 [46] -0.074934095 0.009039812 0.052285088 -0.014309275 > (mypacf <- c(rpacf$acf)) [1] 0.376438488 0.049856780 -0.064774648 -0.101529710 -0.208489661 [6] 0.041068070 0.217485811 -0.076580053 0.072453721 -0.026901544 [11] -0.051901915 0.081349247 0.012123382 0.069896068 -0.136633490 [16] 0.074052527 -0.020028866 0.167242243 0.061874327 -0.074498069 [21] -0.106146501 -0.234046687 0.003916355 0.016298436 0.105396809 [26] 0.042945145 -0.028394965 -0.085583306 -0.168105863 0.138160747 [31] 0.036229243 -0.111542480 -0.027095552 0.060829657 0.001407941 [36] -0.001523559 -0.053119219 0.023148741 -0.062383844 0.052887828 [41] -0.066337560 -0.096708526 0.009767505 -0.145742377 -0.009903680 [46] -0.038378218 0.038330757 -0.079817568 > 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/4qgzi1452539234.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/5vyp81452539234.tab") > > try(system("convert tmp/1ztf81452539234.ps tmp/1ztf81452539234.png",intern=TRUE)) character(0) > try(system("convert tmp/2zdqn1452539234.ps tmp/2zdqn1452539234.png",intern=TRUE)) character(0) > try(system("convert tmp/3pykw1452539234.ps tmp/3pykw1452539234.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.155 0.269 1.420