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(-23.5,-21.1,-20.9,-20.8,-17.3,-16.1,-14.6,-13.9,-9.7,-9.2,-9,-8.1,-7.6,-7.2,-6.8,-6.6,-6.2,-6,-5.6,-5.6,-5.6,-5.4,-5.1,-5,-4.9,-4.8,-4.8,-4.8,-4.7,-4.1,-3.8,-3.7,-3.4,-3.2,-3.1,-3.1,-3.1,-2.8,-2.4,-2.2,-2,-1.8,-1.7,-1.4,-1.4,-1.3,-0.9,-0.8,-0.5,-0.3,-0.3,-0.1,0.1,0.2,0.2,0.3,0.6,1.5,1.7,1.8,2.5,2.6,2.7,2.8,3.3,3.5,3.6,4.3,4.8,4.8,4.8,5.7,5.8,5.9,6,6.3,6.8,6.8,7,7.4,7.5,7.6,7.8,7.9,8,8.1,8.4,8.4,8.5,8.7,8.7,8.7,8.7,8.8,8.9,9.4) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '1' > 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/1d1rm1425298172.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/24iic1425298172.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/3uyrv1425298172.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.867399401 0.755382822 0.631873468 0.483728076 [6] 0.363376954 0.254549228 0.161166584 0.061346723 0.025345681 [11] -0.004271375 -0.041159135 -0.069272996 -0.086385096 -0.093774399 [16] -0.098926104 -0.100749676 -0.093614218 -0.091443715 -0.087788704 [21] -0.084863385 -0.084791358 -0.085635411 -0.083398958 -0.076034558 [26] -0.067059245 -0.065910343 -0.067856394 -0.069545396 -0.075563719 [31] -0.077707620 -0.076417868 -0.077987374 -0.074470230 -0.069831932 [36] -0.070912150 -0.074413371 -0.082547284 -0.084972887 -0.082181196 [41] -0.081141270 -0.075348685 -0.064000104 -0.051635888 -0.034671327 [46] -0.016880033 -0.011634992 -0.001978506 0.012389812 > (mypacf <- c(rpacf$acf)) [1] 0.8673994007 0.0121198730 -0.1046794752 -0.1822623945 0.0018933436 [6] -0.0167535065 -0.0129165949 -0.1255493370 0.1630001216 0.0078377140 [11] -0.0833213192 -0.0868302420 0.0359914108 0.0351654738 -0.0152783038 [16] -0.0640736040 0.0577741632 -0.0029417946 -0.0368849129 -0.0525546956 [21] 0.0085594407 0.0099726256 -0.0020994206 -0.0152849008 0.0274790662 [26] -0.0355981127 -0.0415794888 -0.0222084258 -0.0056964771 0.0068873985 [31] 0.0015825483 -0.0235725683 0.0180088986 -0.0148283065 -0.0464315532 [36] -0.0306201702 -0.0231145707 0.0195725777 0.0170167930 -0.0288549935 [41] 0.0032733356 0.0207609042 -0.0044149738 0.0024732291 -0.0004703354 [46] -0.0305458080 0.0264496323 0.0210066187 > 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/40tz21425298172.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/5fbex1425298172.tab") > > try(system("convert tmp/1d1rm1425298172.ps tmp/1d1rm1425298172.png",intern=TRUE)) character(0) > try(system("convert tmp/24iic1425298172.ps tmp/24iic1425298172.png",intern=TRUE)) character(0) > try(system("convert tmp/3uyrv1425298172.ps tmp/3uyrv1425298172.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.178 0.232 1.418