R version 3.0.1 (2013-05-16) -- "Good Sport" 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(19570,18845,19932,15946,20657,20294,21744,22469,25006,21744,20657,25730,21744,16308,19207,14496,20294,16670,22106,19932,21019,23556,23194,27542,19932,16670,18482,13409,19207,14858,21019,19932,17758,25368,22831,26093,19570,18120,16308,13409,17758,15946,21744,21019,18120,24281,22469,28992,23194,14134,14134,14134,16670,16670,22469,20657,18482,23194,21382,30804,24281,14134,14858,12322,17033,19570,24643,24281,19570,22831,20294,28992,22106,17758,15946,11959,17758,21382,25006,23556,17395,25006,19570,30079,25006,18120,16670,11234,17758,17033,25730,25730,19570,25368,18845,29354,25006,18482,14134,9785,19207,18482,24281,27905,20657,23194,17395,30079) > 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/1umie1376980344.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/2esno1376980345.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/3oell1376980345.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.33667470 0.16906501 -0.23179440 -0.38279167 -0.13151849 [7] -0.33856641 -0.07744727 -0.35463769 -0.21790289 0.13326731 0.29164821 [13] 0.82221969 0.31967102 0.19080064 -0.21197213 -0.37863251 -0.12343766 [19] -0.30250166 -0.04399733 -0.27173193 -0.18108612 0.08736053 0.21649251 [25] 0.66566639 0.31638313 0.19246819 -0.18305667 -0.35036069 -0.14991979 [31] -0.27506902 -0.05108892 -0.20153965 -0.12951030 0.07879093 0.15859189 [37] 0.55652268 0.27728135 0.13592612 -0.14518942 -0.30543044 -0.16486612 [43] -0.27174624 -0.02770843 -0.12625237 -0.07365037 0.07089344 0.10835755 [49] 0.42218019 > (mypacf <- c(rpacf$acf)) [1] 0.336674698 0.062837811 -0.346819673 -0.279260647 0.207080142 [6] -0.405731907 -0.104231281 -0.444306883 -0.286202789 0.159995200 [11] 0.123644881 0.571113615 -0.098600653 -0.005221285 0.026689082 [16] -0.017880389 0.122008844 0.018690900 -0.015146733 0.166704722 [21] -0.017057900 -0.054644945 -0.002619764 -0.055499447 0.129472256 [26] -0.016427751 -0.066874478 0.058543775 -0.089155318 -0.003808940 [31] -0.113296556 -0.012473989 0.110459691 0.001260985 -0.085363127 [36] 0.075857022 -0.152457907 -0.135013271 0.083281206 -0.003353137 [41] -0.017936079 -0.100251657 0.062643254 0.056902885 -0.027346332 [46] -0.106960417 -0.058944158 -0.030856612 > 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/4g2li1376980345.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/5fi681376980345.tab") > > try(system("convert tmp/1umie1376980344.ps tmp/1umie1376980344.png",intern=TRUE)) character(0) > try(system("convert tmp/2esno1376980345.ps tmp/2esno1376980345.png",intern=TRUE)) character(0) > try(system("convert tmp/3oell1376980345.ps tmp/3oell1376980345.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.989 0.445 2.415