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(340,307,380,347,313,333,347,333,387,307,353,407,307,253,380,320,353,353,387,280,387,307,347,427,253,240,407,293,347,360,387,240,333,353,313,440,273,240,407,240,360,373,387,320,373,373,260,420,253,293,413,207,333,440,280,367,380,373,193,373,213,293,407,167,340,447,233,393,333,353,200,413,187,300,413,213,373,453,247,447,340,320,187,380,160,307,400,213,380,453,260,467,380,300,180,427,153,327,393,207,380,440,247,400,360,340,220,393) > 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/1qyto1407246096.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/2zn001407246096.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/3vdd71407246096.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.40526052 -0.04098498 0.37634876 -0.27946468 -0.21510545 [7] 0.25465228 -0.21244047 -0.22032326 0.32457896 -0.03479387 -0.34301053 [13] 0.83033439 -0.39913898 -0.01503560 0.35188953 -0.31446899 -0.14471422 [19] 0.20565025 -0.19883017 -0.13255829 0.26818783 -0.05683535 -0.22042042 [25] 0.61654876 -0.37795071 0.01169121 0.33025945 -0.34806034 -0.06079337 [31] 0.16041737 -0.18593714 -0.06532743 0.23999769 -0.08264832 -0.09698525 [37] 0.42611246 -0.31248594 0.01185056 0.28328188 -0.35199282 0.01332639 [43] 0.10488058 -0.16622757 -0.02510634 0.19064713 -0.10635384 -0.01853726 [49] 0.25076308 > (mypacf <- c(rpacf$acf)) [1] -0.405260520 -0.245549094 0.326150303 0.013143932 -0.407594952 [6] -0.180141325 -0.030533049 -0.235143850 -0.062336463 0.199176452 [11] -0.320070949 0.668892842 0.035120463 0.085547310 -0.083990736 [16] -0.049932224 0.110215068 -0.105874842 0.034372736 0.087227003 [21] 0.039561362 -0.105698781 0.142208048 -0.173834801 -0.027447471 [26] -0.101582071 0.134430298 0.025246335 -0.069286848 -0.070126478 [31] 0.039780257 0.046131123 0.026950070 0.009577813 0.076352807 [36] -0.023498126 0.058457484 -0.035449587 -0.011253194 0.006751522 [41] -0.003815282 -0.038153210 -0.018327579 -0.016126374 -0.090728702 [46] -0.062982804 -0.123484163 -0.081513025 > 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/4feqd1407246096.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/52g891407246096.tab") > > try(system("convert tmp/1qyto1407246096.ps tmp/1qyto1407246096.png",intern=TRUE)) character(0) > try(system("convert tmp/2zn001407246096.ps tmp/2zn001407246096.png",intern=TRUE)) character(0) > try(system("convert tmp/3vdd71407246096.ps tmp/3vdd71407246096.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.212 1.388