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(164.88,164.88,164.57,164.53,165.03,165.92,165.92,165.92,165.92,166.12,166.34,165.48,165.61,165.61,165.94,165.88,166.23,166.32,166.43,166.43,166.2,166.21,168.02,168.68,168.65,168.65,168.75,168.8,168.58,168.98,169,169,168.94,169.96,171.59,172.41,172.65,172.65,172.65,172.38,171.95,171.95,171.87,171.87,171.91,171.99,172.15,172.73,173.2,164.97,164.97,164.43,163.16,162.98,161.69,162.19,162,162.22,164.08,164.58,164.68) > 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/1hwbi1413639929.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/2lxd81413639929.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/3h68i1413639929.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.921861709 0.838986995 0.749218547 0.637136553 [6] 0.528399858 0.411692627 0.306746688 0.207906689 0.112743733 [11] 0.040841435 -0.027846380 -0.104292704 -0.153543878 -0.208498115 [16] -0.257546620 -0.287271891 -0.301349791 -0.315587810 -0.325182952 [21] -0.330606063 -0.328712439 -0.327341042 -0.317285815 -0.303654442 [26] -0.296994169 -0.297863604 -0.296380086 -0.278229453 -0.266334445 [31] -0.257481930 -0.246910789 -0.234195893 -0.219612991 -0.196541482 [36] -0.167354506 -0.132068783 -0.099769878 -0.066463134 -0.045710797 [41] -0.031366042 -0.016421273 -0.002941826 0.008969558 0.017790138 [46] 0.037609251 0.062537109 0.088607253 0.116158579 > (mypacf <- c(rpacf$acf)) [1] 0.921861709 -0.072197806 -0.090335051 -0.199642915 -0.040102296 [6] -0.119064953 0.018822352 -0.044709959 -0.046107550 0.050931759 [11] -0.058695773 -0.153082478 0.073356125 -0.115489629 -0.037048754 [16] 0.033145117 0.071453365 -0.109868745 -0.017698622 -0.067443928 [21] -0.022319304 -0.035986957 0.030955791 -0.059157556 -0.034083846 [26] -0.127550140 -0.043897072 0.083480692 -0.039168934 -0.095507617 [31] -0.025525829 -0.009147462 -0.030616094 0.016741344 0.021849405 [36] 0.013156718 -0.019722668 -0.032278837 -0.132426242 -0.026265999 [41] -0.041144422 -0.004938441 0.024049133 0.004742991 0.023195873 [46] 0.027677532 -0.003616335 -0.013178569 > 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/4fkcd1413639929.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/5r7zz1413639929.tab") > > try(system("convert tmp/1hwbi1413639929.ps tmp/1hwbi1413639929.png",intern=TRUE)) character(0) > try(system("convert tmp/2lxd81413639929.ps tmp/2lxd81413639929.png",intern=TRUE)) character(0) > try(system("convert tmp/3h68i1413639929.ps tmp/3h68i1413639929.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.146 0.188 1.349