R version 3.1.0 (2014-04-10) -- "Spring Dance" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(2.58,2.59,2.6,2.6,2.61,2.62,2.64,2.65,2.66,2.67,2.68,2.69,2.69,2.71,2.72,2.73,2.73,2.74,2.74,2.74,2.74,2.74,2.75,2.75,2.75,2.75,2.77,2.78,2.79,2.8,2.82,2.83,2.84,2.87,2.89,2.9,2.9,2.91,2.92,2.92,2.92,2.92,2.94,2.95,2.95,2.97,2.99,3,3,3.01,3.03,3.03,3.04,3.04,3.05,3.05,3.09,3.09,3.09,3.1,3.1,3.11,3.12,3.12,3.12,3.13,3.15,3.16,3.16,3.18,3.19,3.19,3.2,3.21,3.26,3.27,3.28,3.29,3.29,3.3,3.3,3.31,3.31,3.31) > 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.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) 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) > 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/1yazm1400776934.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/2zgrg1400776934.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/3it5d1400776934.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.96463253 0.92856224 0.89183970 0.85445467 0.81616455 [7] 0.77805142 0.74060589 0.70343848 0.66675146 0.63057010 0.59881817 [13] 0.56769832 0.53624466 0.50523107 0.47502654 0.44651088 0.41665521 [19] 0.38748218 0.35880460 0.32979321 0.29923952 0.26754809 0.23656459 [25] 0.20514615 0.17226128 0.13911845 0.10684550 0.07429954 0.04507565 [31] 0.01552819 -0.01214318 -0.03983471 -0.06694473 -0.09216841 -0.11448450 [37] -0.13573869 -0.15802950 -0.17938482 -0.19854559 -0.21693282 -0.23630609 [43] -0.25588676 -0.27255982 -0.28927834 -0.30690705 -0.32341307 -0.33789129 [49] -0.35115590 > (mypacf <- c(rpacf$acf)) [1] 0.964632530 -0.028116911 -0.028000858 -0.028785819 -0.032966486 [6] -0.018150199 -0.011545315 -0.017479932 -0.014992805 -0.015124781 [11] 0.041304816 -0.012310226 -0.026367575 -0.015638122 -0.010806616 [16] 0.003626535 -0.039110849 -0.011474571 -0.014125497 -0.026115416 [21] -0.040252082 -0.038911207 -0.014773158 -0.029902561 -0.045223862 [26] -0.028158694 -0.018059275 -0.032138050 0.020359343 -0.034575379 [31] -0.005375921 -0.032967643 -0.020591114 -0.003339288 0.009258801 [36] -0.014473776 -0.042207915 -0.016433024 0.006225642 -0.017387840 [41] -0.039012352 -0.031992844 0.012446086 -0.023326390 -0.038558450 [46] -0.010115707 -0.004173380 -0.009546108 > 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/4k63d1400776934.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/5uo6q1400776934.tab") > > try(system("convert tmp/1yazm1400776934.ps tmp/1yazm1400776934.png",intern=TRUE)) character(0) > try(system("convert tmp/2zgrg1400776934.ps tmp/2zgrg1400776934.png",intern=TRUE)) character(0) > try(system("convert tmp/3it5d1400776934.ps tmp/3it5d1400776934.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.525 0.318 1.863