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(69731,68504,67277,64823,89654,88427,69731,57316,58542,58542,59770,62357,54862,47354,41207,41207,64823,67277,48581,27431,38620,38620,47354,52396,51168,38620,44900,42434,63584,58542,38620,23738,37392,41207,44900,49808,39846,31246,34939,36166,68504,68504,49808,47354,54862,51168,61130,73546,76012,58542,53622,48581,82280,84746,78466,84746,83507,73546,84746,97162,102203,87200,77238,84746,117084,127046,124592,129499,128273,115858,137008,142049,149423,127046,118312,128273,152010,173160,168119,168119,170585,161971,184361,184361,180546,159384,163199,165665,181895,203045,188041,195550,189269,185587,214246,207965,199230,186815,199230,205511,213006,222967,213006,219154,211657,210431,241542,244129,234168,216700,231581,237850,245357,256546,245357,254092,250277,236622,265279,265279) > 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/1fd4n1375360639.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/2zm3e1375360639.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/3it0i1375360639.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.018817086 -0.301953414 -0.309552662 -0.140987975 [6] 0.190835428 0.300902482 0.175896291 -0.089053001 -0.332200021 [11] -0.286086971 0.065213413 0.798033924 0.003687524 -0.253093990 [16] -0.244858557 -0.117941559 0.127761911 0.273742186 0.152467403 [21] -0.087043632 -0.325781083 -0.188679746 0.079853032 0.605598261 [26] -0.041294752 -0.189748393 -0.144884791 -0.140569717 0.033674917 [31] 0.280723351 0.155509493 -0.050019068 -0.330091591 -0.180606519 [36] 0.077285972 0.424386209 -0.026103522 -0.115717401 -0.068792298 [41] -0.163473750 -0.056721078 0.274981121 0.183470699 -0.016882769 [46] -0.316524175 -0.159943564 0.038169539 0.317642140 > (mypacf <- c(rpacf$acf)) [1] 0.018817086 -0.302414576 -0.326419499 -0.304042397 -0.070773487 [6] 0.095362586 0.211235621 0.185054141 -0.031136123 -0.240331208 [11] -0.235161428 0.676215600 -0.030316383 0.081389788 0.126613256 [16] 0.182853293 -0.102579075 0.015193822 -0.035660290 -0.122827167 [21] -0.095892408 0.175428553 -0.048516008 -0.064561454 -0.054797780 [26] 0.100360176 0.054771988 -0.125420229 -0.166680404 0.074849089 [31] 0.059922074 0.106193641 -0.059267153 -0.134825915 -0.082746002 [36] -0.121377530 0.009596799 -0.133513339 -0.005240846 0.023998514 [41] 0.085503584 0.061584464 0.090500024 -0.034838437 -0.019558815 [46] 0.039164804 -0.023388280 -0.016659800 > 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/4kr361375360639.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/538aw1375360639.tab") > > try(system("convert tmp/1fd4n1375360639.ps tmp/1fd4n1375360639.png",intern=TRUE)) character(0) > try(system("convert tmp/2zm3e1375360639.ps tmp/2zm3e1375360639.png",intern=TRUE)) character(0) > try(system("convert tmp/3it0i1375360639.ps tmp/3it0i1375360639.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.542 0.590 3.115