R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(177.6 + ,176.5285714 + ,175.7714286 + ,174.9857143 + ,177.3571429 + ,176.3714286 + ,174.1 + ,171.1714286 + ,166.4571429 + ,163.8 + ,161.7857143 + ,156.5142857 + ,152.5428571 + ,149.3142857 + ,146.8142857 + ,144.0571429 + ,141.4142857 + ,134.9571429 + ,128.7428571 + ,124.6571429 + ,119.8714286 + ,117.9857143 + ,118.2857143 + ,115.4142857 + ,115.9714286 + ,116.9714286 + ,121.3571429 + ,131.5714286 + ,137.2428571 + ,136.8714286 + ,139.7857143 + ,146.2 + ,147.0714286 + ,146.9142857 + ,144.5857143 + ,144.3571429 + ,147.3571429 + ,150.0142857 + ,154.8571429 + ,162.0285714 + ,158.6142857 + ,163.6428571 + ,166.6 + ,169.7571429 + ,170.6714286 + ,165.9714286 + ,166.1714286 + ,170.7857143 + ,170.1142857 + ,171.0857143 + ,175.6285714 + ,178.2 + ,176.7285714 + ,177.4428571 + ,179.4142857 + ,175.6714286 + ,174.2571429 + ,169.3 + ,170.0428571 + ,173.9428571 + ,171.2714286 + ,166.7714286 + ,168.7285714 + ,164.7 + ,164.1 + ,156.5142857 + ,150.2 + ,149.4 + ,147.4857143 + ,137.3571429 + ,135.1571429 + ,130.7428571 + ,130.1714286 + ,126.4 + ,122.3428571 + ,120.9571429 + ,124.9857143 + ,124.0428571 + ,127.3 + ,124.9714286 + ,128.7 + ,131.3285714 + ,134.1285714 + ,139.4142857 + ,144 + ,145.6857143 + ,153.4428571 + ,157.9428571 + ,157.9 + ,158.7857143 + ,155.2142857 + ,159.6 + ,158.3714286 + ,161.8714286 + ,165.5857143 + ,168.6142857 + ,170.2428571 + ,176.4142857 + ,171.7285714 + ,174.0571429 + ,170.5714286 + ,168.9285714 + ,171.0857143 + ,173.1571429 + ,172.1857143 + ,177.3 + ,179.0428571 + ,181.5571429 + ,180.5285714 + ,181.5714286 + ,181.8428571 + ,180.9142857 + ,175.6857143 + ,174.1 + ,171.4428571 + ,171.5714286 + ,167.0571429 + ,160.3142857 + ,152.5285714 + ,150.1285714 + ,145.6571429 + ,140.6) > par8 = '' > par7 = '0.95' > par6 = 'MA' > par5 = '1' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'MA' > par5 <- '1' > par4 <- '0' > par3 <- '1' > par2 <- '1' > par1 <- '60' > #'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/17c4b1393881122.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/2aao71393881122.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/3x1td1393881122.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.42705510 0.40011774 0.36783614 0.34122481 0.26845053 [7] 0.22823440 -0.04883141 0.24938722 0.07377225 0.08385718 0.09280101 [13] 0.04588037 -0.07661038 -0.11265102 -0.17956128 -0.09772058 -0.14647121 [19] -0.24014979 -0.19094272 -0.16822054 -0.15591643 -0.20144975 -0.13103262 [25] -0.20000783 -0.20023857 -0.24255115 -0.16834435 -0.25221473 -0.14509508 [31] -0.34460213 -0.22847090 -0.19905028 -0.17298184 -0.22312793 -0.10730051 [37] -0.23750639 -0.06570240 -0.18325652 -0.09870408 -0.08030054 -0.08234043 [43] -0.09374446 0.09275617 0.09283918 0.16214426 0.15111200 0.19873032 [49] 0.20889080 0.22186568 0.21159716 0.19647146 0.26492256 0.22580072 [55] 0.22876971 0.31034986 0.29592941 0.17252115 0.19891774 0.10746682 [61] 0.13922424 > (mypacf <- c(rpacf$acf)) [1] 0.4270550956 0.2663103102 0.1694752807 0.1150548723 0.0131704313 [6] -0.0031650291 -0.3402519067 0.3120124327 -0.0889159673 0.0581445084 [11] 0.0621010972 -0.0776682347 -0.1859794580 -0.3073306151 0.1192983686 [16] -0.0465142715 0.1248900707 -0.0901648691 0.0009034968 -0.1142683657 [21] -0.1001181452 0.0107067283 0.1286097328 -0.0166361627 -0.1447952891 [26] -0.0629645862 -0.0746028788 -0.1935899000 0.1394951929 -0.1810463814 [31] -0.0277984871 -0.0615678584 -0.0209136067 -0.0293974684 -0.0349867976 [36] 0.0126855945 -0.1155102884 -0.0860910036 -0.0238162914 0.0066898408 [41] -0.0070850924 0.0150773828 0.1140425560 0.0801749102 -0.0915198545 [46] 0.0453246210 0.0561502102 -0.0937450195 -0.0033316032 0.1230531515 [51] -0.0309859743 0.0283449731 0.0540165236 -0.0254362309 0.0513175118 [56] -0.0461527301 -0.0272774744 -0.0925441897 0.0107483911 -0.0542871879 > 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/4aysj1393881122.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/5pnyr1393881122.tab") > > try(system("convert tmp/17c4b1393881122.ps tmp/17c4b1393881122.png",intern=TRUE)) character(0) > try(system("convert tmp/2aao71393881122.ps tmp/2aao71393881122.png",intern=TRUE)) character(0) > try(system("convert tmp/3x1td1393881122.ps tmp/3x1td1393881122.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.876 0.562 3.430