R version 3.3.3 (2017-03-06) -- "Another Canoe" Copyright (C) 2017 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(88,90,82,75,79,70,71,75,89,92,94,90,102,98,100,98,100,91,93,92,106,109,108,108,118,119,124,118,119,113,114,115,125,125,118,122,132,133,136,128,126,114,108,107,117,119,113,114,124,125,124,118,111,99,94,93,107,107,103,97,103,107,104,101,92,85,83,77,90,87,87,78) > 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/1xjg21489776416.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/2wos61489776416.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/3hco01489776416.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.90015191 0.80149573 0.69206197 0.62991139 0.53715359 [7] 0.46699855 0.39691568 0.36119732 0.32569984 0.33790109 0.36500682 [13] 0.37246443 0.27823915 0.17118485 0.06973368 0.01176466 -0.07751361 [19] -0.15562937 -0.22878280 -0.26547219 -0.29834963 -0.28875749 -0.26194919 [25] -0.24037879 -0.28751554 -0.35218337 -0.40028021 -0.42036581 -0.46817179 [31] -0.50238111 -0.53110322 -0.52364560 -0.51427216 -0.46142094 -0.39806768 [37] -0.32844864 -0.30874595 -0.30617412 -0.29158684 -0.26142805 -0.25948170 [43] -0.25718324 -0.26026702 -0.23506180 -0.20775049 -0.14467718 -0.08216592 [49] -0.01592800 > (mypacf <- c(rpacf$acf)) [1] 0.900151906 -0.046265116 -0.111657818 0.187259111 -0.208586360 [6] 0.049679782 0.018657531 0.052094392 0.030210595 0.208889031 [11] 0.125250871 -0.164207293 -0.502703323 -0.180822022 -0.027743368 [16] 0.128896271 -0.029236992 -0.005365995 0.012567733 -0.046928911 [21] -0.113702150 -0.075661270 -0.004167006 0.054621416 -0.060271478 [26] -0.114952581 -0.025100623 -0.047828730 -0.085480031 0.101004152 [31] 0.025421624 0.014682982 -0.038757792 0.010184181 -0.063945782 [36] -0.002711666 0.059386581 -0.034506898 0.048319644 -0.002368221 [41] -0.088299654 -0.000453377 -0.097752480 0.006911471 0.065209049 [46] 0.072433535 -0.067361436 -0.105991912 > 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/4p8su1489776416.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/5s23f1489776416.tab") > > try(system("convert tmp/1xjg21489776416.ps tmp/1xjg21489776416.png",intern=TRUE)) character(0) > try(system("convert tmp/2wos61489776416.ps tmp/2wos61489776416.png",intern=TRUE)) character(0) > try(system("convert tmp/3hco01489776416.ps tmp/3hco01489776416.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.355 0.092 1.471