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(1.26,1.27,1.24,1.25,1.27,1.25,1.26,1.27,1.26,1.26,1.28,1.27,1.28,1.27,1.26,1.27,1.27,1.28,1.27,1.26,1.3,1.31,1.28,1.29,1.31,1.29,1.29,1.32,1.3,1.29,1.31,1.29,1.33,1.35,1.32,1.33,1.34,1.34,1.33,1.33,1.35,1.32,1.35,1.32,1.36,1.37,1.34,1.32,1.34,1.32,1.33,1.35,1.33,1.33,1.35,1.33,1.36,1.39,1.37,1.37,1.39,1.37,1.39,1.39,1.39,1.37,1.38,1.37,1.41,1.41,1.42,1.42) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/fisher/rcomp/tmp/1368k1356711841.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/2fq731356711841.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/3sk991356711841.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.873986723 0.816631726 0.786530398 0.709364081 [6] 0.683560447 0.673375262 0.614133473 0.574703005 0.545230608 [11] 0.481795947 0.465531097 0.455660377 0.390338924 0.339378057 [16] 0.289779874 0.248777079 0.235761705 0.209224319 0.168535989 [21] 0.159189378 0.129716981 0.110831586 0.109765898 0.111530398 [26] 0.079332635 0.051537386 0.008962264 -0.030258560 -0.043064291 [31] -0.074528302 -0.102323550 -0.134416492 -0.138626834 -0.154577219 [36] -0.175139762 -0.181761006 -0.214797345 -0.226554857 -0.262631027 [41] -0.293885395 -0.278808526 -0.306603774 -0.304734451 -0.306219427 [46] -0.321540881 -0.313801537 -0.302603075 -0.332285115 -0.341212439 [51] -0.339133473 -0.369968553 -0.381201957 -0.369793850 -0.382180294 [56] -0.384189378 -0.374563242 -0.369025157 -0.337491265 -0.321156534 [61] -0.316666667 > (mypacf <- c(rpacf$acf)) [1] 0.873986723 0.223500143 0.164860600 -0.140527978 0.122751574 [6] 0.117501444 -0.109533011 -0.050817863 0.008432094 -0.082779889 [11] 0.088634972 0.053110893 -0.159301968 -0.131187690 -0.064118507 [16] 0.105470889 0.068644861 -0.068928160 -0.073617655 0.092903628 [21] 0.018419018 0.060046839 -0.025782893 0.057040430 -0.116236146 [26] -0.053425281 -0.081252706 -0.059440509 -0.033117750 -0.065619658 [31] -0.004683875 -0.089363926 0.141901823 0.002291492 -0.065480186 [36] -0.042303648 -0.063739729 0.113184426 -0.101703368 -0.085924838 [41] 0.124883547 -0.132933293 0.148632565 -0.071030311 -0.042060558 [46] 0.005648338 -0.006560909 -0.105772838 -0.059879590 -0.023351375 [51] -0.017690670 -0.027194035 -0.002046205 0.024130337 -0.057897332 [56] 0.064923656 0.079633811 0.051471798 -0.064333258 0.010771631 > 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/4dry81356711841.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/5zq1z1356711841.tab") > > try(system("convert tmp/1368k1356711841.ps tmp/1368k1356711841.png",intern=TRUE)) character(0) > try(system("convert tmp/2fq731356711841.ps tmp/2fq731356711841.png",intern=TRUE)) character(0) > try(system("convert tmp/3sk991356711841.ps tmp/3sk991356711841.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.856 0.509 2.361