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(9969,9692,8943,8802,8250,8515,13973,13905,12467,9490,8483,7610,7839,7107,6584,6053,5725,6480,11663,11628,9203,7781,7020,6908,6912,6668,6189,6007,5148,6685,11044,11034,8986,8146,7818,8176,8935,8929,8835,8455,7924,8973,13575,13844,11738,10467,10145,10833,10179,10107,9533,9165,8382,9018,13911,13761,11316,9855,9034,8932,9278,8876,8298,7733,7226,7688,12226,12081,10439,9008,8377,8346,9167,8945,8428,7973,7446,7785,10561,12791,11583,10112,9597,9332) > 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/wessaorg/rcomp/tmp/1d3wp1384333713.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/2wlnd1384333713.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/3s2r51384333713.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.247656877 -0.328247452 -0.354678187 -0.164047405 [6] 0.028489993 0.171340427 0.057032775 -0.132920360 -0.306525262 [11] -0.306145455 0.203206587 0.802619768 0.240939066 -0.306102748 [16] -0.285063611 -0.149513938 0.035501187 0.130713219 0.052214671 [21] -0.114880715 -0.251717441 -0.269128881 0.150319706 0.639835052 [26] 0.212415506 -0.246681781 -0.246032723 -0.116579426 0.027601531 [31] 0.112332466 0.033231014 -0.083641909 -0.198128337 -0.208919172 [36] 0.112433828 0.517165708 0.186320465 -0.186534096 -0.181090279 [41] -0.101870581 0.024818749 0.082859288 0.031832779 -0.072586193 [46] -0.154894605 -0.137338054 0.077021585 0.390802708 0.140241525 [51] -0.116011424 -0.144053200 -0.085277885 -0.002565687 0.076973981 [56] 0.009477999 -0.048154600 -0.111663651 -0.083009639 0.038597521 [61] 0.247843978 > (mypacf <- c(rpacf$acf)) [1] 0.2476568772 -0.4150372454 -0.1761434478 -0.1833406707 -0.1035230489 [6] 0.0113640639 -0.1235903192 -0.1499349780 -0.3529667362 -0.4866570011 [11] -0.0994790031 0.5815974587 -0.1375188985 -0.0361879708 0.1887454303 [16] -0.0247277411 0.0810046942 -0.0866547299 -0.0333811069 -0.0189863994 [21] -0.0295318169 -0.0373443854 -0.1034200475 -0.0626053737 -0.0832251115 [26] 0.0040633728 -0.1373719795 -0.0331535391 -0.0766211918 -0.0584962396 [31] -0.0862838573 -0.0620785021 -0.0435677528 -0.0166931242 -0.0474385402 [36] -0.0176870721 -0.0273331168 0.0184855226 0.0732449914 -0.0513439863 [41] 0.0359480096 0.0008622961 0.0358258715 -0.0174466239 -0.0363566736 [46] 0.1210061341 -0.0830382490 -0.0200523391 -0.0660097367 0.0686286552 [51] -0.1120349338 -0.0178544013 -0.0884694297 0.0042293014 -0.0842958028 [56] -0.0012543816 0.0153930647 -0.0446771698 -0.0012816882 -0.1241227987 > 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/4r60d1384333713.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/5nddg1384333713.tab") > > try(system("convert tmp/1d3wp1384333713.ps tmp/1d3wp1384333713.png",intern=TRUE)) character(0) > try(system("convert tmp/2wlnd1384333713.ps tmp/2wlnd1384333713.png",intern=TRUE)) character(0) > try(system("convert tmp/3s2r51384333713.ps tmp/3s2r51384333713.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.893 0.375 2.246