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(99.49,99.84,100.9,101.31,100.09,99.28,99.57,101.04,101.87,101.39,100.3,99.95,99.87,100.51,100.27,100.04,99.23,99.32,99.95,100.23,101.02,99.83,99.61,100.12,99.83,100.03,100.07,100.46,100.43,100.68,101.8,101.21,100.63,100.55,99.76,98.8,96.59,97.59,98.79,98.79,99.65,99.78,100.05,99.22,97.72,97.55,98.14,97.95,97.24,97.02,97.57,98.07,98.86,99.57,100.14,99.88,99.79,100.59,100.55,101.42) > 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/151uw1490093258.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/2azc71490093258.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/3zkg31490093258.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.233923319 -0.208603566 -0.246376885 -0.113506360 [6] 0.136800980 -0.112428695 0.008866845 -0.039590141 -0.165850541 [11] 0.052673752 0.131786207 0.252958825 0.024580200 -0.155094208 [16] -0.021918540 -0.121581047 -0.008960909 -0.129739392 -0.032315516 [21] 0.101582818 -0.037207618 0.091380046 -0.003560454 -0.018902415 [26] -0.068872844 -0.015341121 0.069479689 -0.081019411 -0.080655583 [31] 0.029151027 0.079761759 0.082736570 -0.021907410 0.022356302 [36] -0.010577062 -0.119903535 -0.072762185 0.016533708 0.167676355 [41] 0.038539884 -0.121177279 -0.134691141 -0.026150075 0.077091780 [46] 0.033113228 0.004361318 -0.053439356 -0.060736796 > (mypacf <- c(rpacf$acf)) [1] 0.2339233186 -0.2785668986 -0.1362764431 -0.0781794121 0.1130844005 [6] -0.2924997606 0.1701007606 -0.1837480243 -0.1499930730 0.0855467245 [11] 0.0976937310 0.0961469201 -0.0020999195 0.0085861742 0.0245210894 [16] -0.1455295456 0.0287623038 -0.2194229743 0.0848103993 -0.0365669364 [21] -0.0089804005 0.0125923490 -0.0399619671 -0.0901841477 -0.1135954992 [26] 0.1495840338 -0.1652791333 0.0252634325 -0.0214441596 0.0932145975 [31] -0.0435839216 0.0342410651 0.0065058983 -0.0370413491 0.0148166678 [36] -0.1156961005 -0.0582998946 0.0687580032 0.0782082547 0.0012535896 [41] -0.1404017122 -0.0827009999 -0.1016920259 -0.0097345078 -0.0473304975 [46] -0.0425201120 0.0002607688 0.0094384198 > 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/4h27g1490093258.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/5fh1p1490093258.tab") > > try(system("convert tmp/151uw1490093258.ps tmp/151uw1490093258.png",intern=TRUE)) character(0) > try(system("convert tmp/2azc71490093258.ps tmp/2azc71490093258.png",intern=TRUE)) character(0) > try(system("convert tmp/3zkg31490093258.ps tmp/3zkg31490093258.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.152 0.105 1.275