R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 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(6,6.7,-0.6,5.8,16.4,1.5,5.1,14.7,4.3,1.5,9.1,4.3,5.7,13,14.5,9.7,-4.7,7.3,5.2,-2.5,11.5,4.9,-2.4,-0.3,4.4,7.9,-9.7,-4.1,16.4,-4.9,3.5,3.8,-0.2,3.1,0.7,-2.8,5.9,-5.3,-2.9,6.6,-8.1,1.3,6.9,-7.2,-1.9,4,-5.7,3.9,-7.6,-0.9,7.3,-3.7,-2.5,9.3,1.3,9.5,11.3,-1.7,8,-4.8,1.6,1.9,-0.9,5.5,1.7,-5.4,1.9,0.2,-13.3,-8.2,0.2,5.7,-1.2,-2.8,5.5,-17.3,1.4,-2.2,-8.6,-5,4.1,0.7,-4.2,-2.3) > 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/1kz3z1394716696.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/29efj1394716696.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/364f41394716696.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.04539912 0.02140262 0.48536729 0.06503510 0.11980330 [7] 0.19986275 0.14367139 0.27750325 -0.01637591 0.14080634 0.29949188 [13] -0.28364835 0.05836713 0.23861692 -0.16934282 0.05081332 0.10064172 [19] -0.03821098 -0.03166417 -0.10602640 0.09266864 0.01448956 -0.20954514 [25] 0.09321028 0.05253292 -0.12928590 0.06001387 -0.01653742 -0.03002538 [31] 0.02457400 -0.06808762 0.08850999 -0.04834141 -0.13156262 0.17112994 [37] -0.06413372 -0.11793134 0.12723320 -0.04331596 -0.03548022 0.05191116 [43] 0.03325737 0.13286445 -0.07577147 -0.08112408 0.16484871 -0.12018072 [49] -0.04822358 > (mypacf <- c(rpacf$acf)) [1] 0.045399115 0.019381485 0.484715303 0.034104476 0.141319076 [6] -0.052369642 0.134786893 0.211555061 -0.133914142 0.048126816 [11] 0.070798331 -0.355888125 -0.059056260 0.007627452 0.029135907 [16] 0.004710559 0.009216179 0.025649139 -0.082928328 -0.021072745 [21] 0.093178013 0.065422581 -0.022198011 -0.117463832 0.012263168 [26] 0.101732247 0.038079685 -0.050045261 0.034917432 0.034969532 [31] -0.094262023 0.019641784 -0.018411131 -0.061287907 0.050222690 [36] -0.073422321 -0.010168031 0.036721510 0.025118409 0.019365936 [41] 0.063159739 0.140066706 0.095383649 -0.056306958 -0.170241322 [46] -0.071984363 -0.046754370 -0.002005517 > 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/444cc1394716696.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/5xris1394716696.tab") > > try(system("convert tmp/1kz3z1394716696.ps tmp/1kz3z1394716696.png",intern=TRUE)) character(0) > try(system("convert tmp/29efj1394716696.ps tmp/29efj1394716696.png",intern=TRUE)) character(0) > try(system("convert tmp/364f41394716696.ps tmp/364f41394716696.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.235 0.439 2.732