R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(8.41,8.39,8.43,8.44,8.49,8.47,8.53,8.52,8.51,8.53,8.54,8.53,8.47,8.63,8.67,8.73,8.57,8.55,8.63,8.65,8.44,8.62,8.37,8.59,8.84,8.72,8.8,8.69,8.68,8.57,8.85,8.85,8.85,8.93,8.75,8.78,8.77,9.03,9.01,9.07,8.99,9.02,8.99,8.98,8.94,8.94,8.75,8.86,8.87,8.84,8.84,9.91,10.18,10.34,10.36,10.26,10.16,10.31,10.46,10.54,10.47,10.48,10.46,11.3,11.58,11.69,11.63,11.51,11.37,11.42,11.7,11.75) > 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/fisher/rcomp/tmp/1kczm1353772297.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/fisher/rcomp/tmp/2j1zb1353772297.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/fisher/rcomp/tmp/3k4k61353772297.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.93934508 0.87473794 0.81681430 0.76475833 0.71117326 [7] 0.65549882 0.59137356 0.52527285 0.46974992 0.44142137 0.41189509 [13] 0.37972148 0.33036035 0.28097566 0.23269171 0.19092735 0.14488343 [19] 0.10019666 0.05509914 0.01255391 -0.02530441 -0.03156152 -0.04123661 [25] -0.04766504 -0.05104614 -0.05095428 -0.05787312 -0.07019749 -0.08862437 [31] -0.10464208 -0.11973884 -0.13058713 -0.14305539 -0.15807805 -0.17702945 [37] -0.18584428 -0.19300811 -0.19637342 -0.20635934 -0.21584287 -0.23068730 [43] -0.24326632 -0.24824737 -0.25399801 -0.26024504 -0.27114988 -0.28308705 [49] -0.29701117 > (mypacf <- c(rpacf$acf)) [1] 0.9393450804 -0.0648744980 0.0236216130 0.0144166965 -0.0430367566 [6] -0.0434590056 -0.1042145828 -0.0553603894 0.0410463054 0.1855434173 [11] -0.0367823286 -0.0170352677 -0.1629969709 -0.0412152009 -0.0592493793 [16] -0.0170658447 -0.0721923815 0.0185092785 0.0193571563 -0.0175909852 [21] -0.0184405104 0.1863526896 -0.0616960373 0.0337266122 0.0294662641 [26] -0.0116962179 -0.0746979357 -0.0939267678 -0.0816074953 0.0212039475 [31] 0.0676709202 -0.0004732362 0.0002017736 -0.0781424698 -0.0596503605 [36] 0.0043052842 -0.0530799504 -0.0279326359 -0.0273232852 0.0337759096 [41] -0.0512517399 -0.0174230867 0.0740253790 -0.0605768606 0.0402667567 [46] -0.0511751731 -0.0279764703 -0.1184525259 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4k5jj1353772297.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/fisher/rcomp/tmp/5o0bo1353772298.tab") > > try(system("convert tmp/1kczm1353772297.ps tmp/1kczm1353772297.png",intern=TRUE)) character(0) > try(system("convert tmp/2j1zb1353772297.ps tmp/2j1zb1353772297.png",intern=TRUE)) character(0) > try(system("convert tmp/3k4k61353772297.ps tmp/3k4k61353772297.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.800 0.469 2.247