R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" 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(339,139,186,155,153,222,102,107,188,162,185,24,394,209,248,254,202,258,215,309,240,258,276,48,455,345,311,346,310,297,300,274,292,304,186,14,321,206,160,217,204,246,234,175,364,328,158,40,556,193,221,278,230,253,240,252,228,306,206,48,557,279,399,364,306,471,293,333,316,329,265,61,679,428,394,352,387,590,177,199,203,255,261,115) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/wessaorg/rcomp/tmp/17jx51384347217.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/2wwtx1384347217.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/3xsxl1384347217.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.03538262 0.13731179 0.24468430 0.17389764 0.24235718 [7] -0.14720104 0.11931936 0.03814408 0.08127002 -0.01423071 -0.19947416 [13] 0.52748063 -0.16072445 -0.05014135 0.02938102 -0.03357418 0.06097324 [19] -0.19514864 -0.03939554 -0.02748216 -0.02108526 -0.12075623 -0.22874678 [25] 0.30155465 -0.17319673 -0.08959088 -0.03528398 0.02460516 0.09862167 [31] -0.11475896 0.01732716 0.05958760 0.08966983 -0.05144403 -0.10030404 [37] 0.27865177 -0.12901497 -0.02976188 -0.02886530 0.02845250 0.06090302 [43] -0.09670338 0.06757281 0.03850985 0.09096520 0.03182214 -0.05129121 [49] 0.26367646 -0.06129774 0.02451211 -0.02496628 -0.01804711 0.01724552 [55] -0.18188902 -0.02547002 -0.10773022 -0.06195195 -0.07634762 -0.19401046 [61] 0.06125387 > (mypacf <- c(rpacf$acf)) [1] 0.035382617 0.136230415 0.240424920 0.160499577 0.204758834 [6] -0.259290728 -0.022182607 -0.066351142 0.121218458 -0.012151933 [11] -0.177050406 0.544456906 -0.256439168 -0.095055595 -0.139863906 [16] -0.091229061 -0.118858079 0.149296855 -0.059708291 0.143682570 [21] -0.070673693 -0.131629037 -0.012507849 -0.011508547 0.009238835 [26] 0.035799155 -0.031241628 0.161190910 0.077221043 -0.074539059 [31] 0.062825815 -0.078305528 0.006163349 -0.013415690 0.052160121 [36] 0.028784682 -0.077621249 -0.068435407 0.038919830 -0.081024643 [41] -0.023521605 0.084140382 0.123129443 0.006768470 0.013291474 [46] 0.108303394 -0.083122877 -0.009693992 0.028193302 0.013287138 [51] -0.058258605 -0.068205024 -0.096644474 -0.106546364 -0.059861251 [56] -0.080890973 0.016863816 -0.028850198 0.007890881 -0.124224853 > 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/48irj1384347217.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/5fcpg1384347217.tab") > > try(system("convert tmp/17jx51384347217.ps tmp/17jx51384347217.png",intern=TRUE)) character(0) > try(system("convert tmp/2wwtx1384347217.ps tmp/2wwtx1384347217.png",intern=TRUE)) character(0) > try(system("convert tmp/3xsxl1384347217.ps tmp/3xsxl1384347217.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.059 0.423 2.460