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(20,23,27,23,21,18,16,11,14,-3,2,26,11,11,11,3,8,8,7,3,4,-7,0,-5,5,-1,-4,4,7,6,13,20,21,37,52,59,66,73,71,69,63,68,58,50,50,50,47,60,62,63,56,38,45,39,26,25,19,14,6,4,5,-3,-5,0,-6,4,-3,14,16,17,25,25,30,51,31,31,25,35,39,48,41,47,61,55,63,45,62,55,50,52,45,36,40,32,29,24,28,27,33,33,24,26,38,32,30,26,21,21) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1k3yu1432984449.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/2mt7k1432984449.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/3z72u1432984449.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.0000000000 -0.1790406175 0.1174230113 0.1534766082 -0.0021444233 [6] 0.0868683032 0.0826220063 -0.1133214775 0.0006846142 -0.0532923091 [11] 0.0005346424 0.0445805430 -0.0999749365 0.0367501042 -0.0092570738 [16] -0.0750174366 -0.0037289670 -0.0417929391 -0.1715779833 0.0252107516 [21] -0.0817093775 -0.0732141670 -0.1766894979 -0.0057699243 -0.1377922297 [26] -0.0385605542 -0.0330085496 -0.1966988486 -0.1722827252 0.0387177932 [31] 0.0033780781 0.0139075243 0.0502490724 -0.0080856003 0.1644196951 [36] 0.0045815723 0.1210252966 0.1223124392 -0.0412464904 0.1106762679 [41] -0.0607051139 0.0091807548 0.0602728337 0.0144142757 -0.0386961401 [46] 0.1417735927 0.0236353106 0.0071716570 0.0162626744 > (mypacf <- c(rpacf$acf)) [1] -0.179040617 0.088194594 0.196202947 0.050438993 0.058475451 [6] 0.078866127 -0.118140844 -0.096147627 -0.084243451 0.014812695 [11] 0.083197580 -0.042387037 0.028191496 0.006798633 -0.076292094 [16] -0.074163062 -0.046042750 -0.158738076 -0.029371646 -0.009296304 [21] -0.020767188 -0.196625165 -0.034736212 -0.107238438 -0.069986116 [26] -0.023811790 -0.193407903 -0.282564870 -0.083611627 0.052250506 [31] 0.074729546 0.089686760 0.016370770 0.097906497 -0.063264231 [36] -0.048980097 0.068290912 -0.010451015 0.030310649 -0.169600361 [41] -0.047757100 -0.046068047 -0.003913906 -0.106176060 0.017011217 [46] 0.015317504 -0.071498987 -0.154068753 > 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/4wfla1432984449.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/5hlv01432984449.tab") > > try(system("convert tmp/1k3yu1432984449.ps tmp/1k3yu1432984449.png",intern=TRUE)) character(0) > try(system("convert tmp/2mt7k1432984449.ps tmp/2mt7k1432984449.png",intern=TRUE)) character(0) > try(system("convert tmp/3z72u1432984449.ps tmp/3z72u1432984449.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.169 0.242 1.401