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.38,1.96,1.36,1.24,1.35,1.23,1.09,1.08,1.33,1.35,1.38,1.5,1.47,2.09,1.52,1.29,1.52,1.27,1.35,1.29,1.41,1.39,1.45,1.53,1.45,2.11,1.53,1.38,1.54,1.35,1.29,1.33,1.47,1.47,1.54,1.59,1.5,2,1.51,1.4,1.62,1.44,1.29,1.28,1.4,1.39,1.46,1.49,1.45,2.05,1.59,1.42,1.73,1.39,1.23,1.37,1.51,1.47,1.5,1.54,1.54,2.15,1.62,1.4,1.65,1.49,1.45,1.45,1.51,1.48,1.56,1.57) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1q98v1353948278.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/2m03q1353948278.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/3g11a1353948278.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.395868285 -0.188152418 0.286350855 -0.133162161 [6] 0.003098897 -0.139857016 0.010223437 -0.131378129 0.251313112 [11] -0.129984939 -0.336764081 0.796241831 -0.318952942 -0.161352753 [16] 0.268866116 -0.129195071 0.005257446 -0.108601432 0.012533573 [21] -0.094479761 0.174463051 -0.094317152 -0.271979386 0.624682837 [26] -0.245130939 -0.126574616 0.220282769 -0.088762797 -0.025767360 [31] -0.074656739 0.023400141 -0.076939392 0.119408587 -0.071363083 [36] -0.207697427 0.475976574 -0.180150658 -0.108425912 0.182065246 [41] -0.063006072 -0.020717587 -0.063520210 0.024164885 -0.051991699 [46] 0.075460281 -0.060014786 -0.129520847 0.326153848 -0.113299385 [51] -0.087698241 0.123400229 -0.037990818 -0.020572533 -0.033234044 [56] 0.000746680 -0.010644225 0.032864052 -0.025252830 -0.065389339 [61] 0.154824789 > (mypacf <- c(rpacf$acf)) [1] -0.395868285 -0.408951621 0.027790629 -0.056617231 0.038012810 [6] -0.270384928 -0.225223259 -0.506812343 -0.004804536 -0.206960213 [11] -0.686730775 0.198045768 -0.066189340 0.003781051 -0.090662200 [16] -0.108237745 -0.123838198 -0.069103517 -0.070808615 0.078356516 [21] -0.051529551 -0.071749276 -0.094799923 -0.109886851 -0.053625856 [26] 0.032984620 -0.060598535 0.063348899 -0.126330495 -0.055471547 [31] -0.047638149 0.008830515 0.006522215 0.002403692 -0.036935276 [36] -0.044674140 -0.048460316 -0.045566039 -0.022476611 -0.083302217 [41] 0.004954396 -0.051878977 -0.061345315 -0.038474666 -0.054539566 [46] -0.075313181 0.075653500 -0.067719070 0.077192214 0.003894492 [51] -0.022860650 -0.059729956 -0.062190262 0.003324764 -0.005834534 [56] 0.006036369 -0.040069619 0.055441431 0.107749267 -0.031811798 > 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/4c84n1353948278.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/5zgwp1353948278.tab") > > try(system("convert tmp/1q98v1353948278.ps tmp/1q98v1353948278.png",intern=TRUE)) character(0) > try(system("convert tmp/2m03q1353948278.ps tmp/2m03q1353948278.png",intern=TRUE)) character(0) > try(system("convert tmp/3g11a1353948278.ps tmp/3g11a1353948278.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.833 0.452 2.269