R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(109.03,110.43,111.01,111.01,110.76,111.13,111.07,111.09,110.96,110.64,110.62,110.59,111.33,113.94,114.61,114.64,114.62,114.71,114.72,114.66,114.76,114.68,114.75,114.74,116.36,117.53,118.82,119.83,119.97,121.29,120.94,121.02,120.98,121.02,120.89,120.76,123.28,123.98,125.91,125.84,125.98,127.24,127.23,127.82,127.59,127.74,127.44,127.35,128.54,129.3,130.67,130.76,131.34,130.69,130.96,130.68,130.61,130.59,130.44,129.04,131.46,132.77,134.48,134.52,136.11,136.12,136.03,135.84,137.75,137.45,136.84,136.79,140.12,140.68,140.35,140.42,140.19,140.14,140.13,139.45,139.59,139.44,139.53,139.28) > 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/1vcpn1413829079.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/26toi1413829079.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/38k621413829079.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.96929677 0.93898162 0.90832799 0.87719451 0.84412442 [7] 0.81047180 0.77680967 0.74261423 0.70671228 0.67016420 0.63139889 [13] 0.59103403 0.55290104 0.51834011 0.48230167 0.44580168 0.41149856 [19] 0.37722640 0.34280334 0.30796960 0.27537483 0.24239851 0.21111486 [25] 0.17959196 0.15200273 0.12242076 0.09381190 0.06662220 0.03870516 [31] 0.01302348 -0.01309465 -0.04081584 -0.06812045 -0.09519318 -0.12118736 [37] -0.14814029 -0.17092406 -0.19409309 -0.21447762 -0.23542228 -0.25671750 [43] -0.27457012 -0.29246401 -0.30751825 -0.32322654 -0.33871410 -0.35189728 [49] -0.36549961 > (mypacf <- c(rpacf$acf)) [1] 0.9692967672 -0.0091724086 -0.0211940401 -0.0240724520 -0.0487226983 [6] -0.0279836858 -0.0185643655 -0.0272835998 -0.0470487488 -0.0317035900 [11] -0.0587979568 -0.0506620283 0.0130709692 0.0375067143 -0.0438482373 [16] -0.0308856045 0.0101070653 -0.0258083985 -0.0247990859 -0.0300814750 [21] 0.0082000940 -0.0336708516 -0.0002238815 -0.0352302946 0.0354475654 [26] -0.0522367777 -0.0125555288 -0.0081109644 -0.0406104481 0.0143465799 [31] -0.0387158286 -0.0601345101 -0.0248535178 -0.0250479763 -0.0181676794 [36] -0.0460538141 0.0434622297 -0.0355763306 0.0115246738 -0.0366270627 [41] -0.0348099739 0.0249709051 -0.0249414232 0.0122534587 -0.0436810682 [46] -0.0295105075 0.0061330061 -0.0462688016 > 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/4ll5o1413829079.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/5iple1413829079.tab") > > try(system("convert tmp/1vcpn1413829079.ps tmp/1vcpn1413829079.png",intern=TRUE)) character(0) > try(system("convert tmp/26toi1413829079.ps tmp/26toi1413829079.png",intern=TRUE)) character(0) > try(system("convert tmp/38k621413829079.ps tmp/38k621413829079.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.178 0.189 1.379