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(-2.5,4.4,13.7,12.3,13.4,2.2,1.7,-7.2,-4.8,-2.9,-2.4,-2.5,-5.3,-7.1,-8,-8.9,-7.7,-1.1,4,9.6,10.9,13,14.9,20.1,10.8,11,3.8,10.8,7.6,10.2,2.2,-0.1,-1.7,-4.8,-9.9,-13.5,-18.1,-18,-15.7,-15.2,-15.1,-17.9,-14.5,-9.4,-4.2,-2.2,4.5,12.4,15.8,11.5,14.1,18.8,26.1,27.9,25.4,23.4,11.5,9.9,8.1,12.6,8.2,5.4,1,-2.9,-3.7,-7,-7.2,-11.8,-2.1,1.2,2.5,4.8,-6.6,-16,-22.7,-17.7,-18.2,-18.9,-16,-12.2,-17.1,-18.6,-17.5,-24.9) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '36' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '36' > #'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/19rrd1384796811.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/2gdh01384796811.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/3h5oe1384796811.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.903811948 0.793008807 0.646513676 0.529052733 [6] 0.421382366 0.318662561 0.207702778 0.083278473 -0.039811146 [11] -0.176816720 -0.296574658 -0.392843667 -0.430492979 -0.439748654 [16] -0.417780954 -0.383702774 -0.366971666 -0.347160192 -0.320000044 [21] -0.291853340 -0.254067044 -0.219582171 -0.153921594 -0.095892121 [26] -0.038865876 -0.015773825 0.001073543 0.011615983 0.037949075 [31] 0.067933655 0.090778051 0.104779064 0.095230326 0.088171920 [36] 0.079835133 0.090917324 > (mypacf <- c(rpacf$acf)) [1] 0.903811948 -0.130333730 -0.254615575 0.102337766 -0.006111844 [6] -0.123485652 -0.125373760 -0.145749275 -0.078906332 -0.206679671 [11] -0.082996219 0.006007792 0.153409687 0.010353896 0.034521312 [16] 0.077305005 -0.145465859 -0.050525224 0.028235849 -0.149145515 [21] -0.076341843 -0.112955593 0.165832714 -0.009876174 -0.033342764 [26] -0.054350961 0.070004373 0.021845054 -0.002736313 0.004432654 [31] -0.046249973 -0.110321476 -0.098835023 0.015460524 0.091529307 [36] 0.088250846 > 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/4lthe1384796811.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/55ww11384796811.tab") > > try(system("convert tmp/19rrd1384796811.ps tmp/19rrd1384796811.png",intern=TRUE)) character(0) > try(system("convert tmp/2gdh01384796811.ps tmp/2gdh01384796811.png",intern=TRUE)) character(0) > try(system("convert tmp/3h5oe1384796811.ps tmp/3h5oe1384796811.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.474 0.536 2.980