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(99.42,99.42,99.42,99.42,99.42,109.26,110,110,109.26,100.07,100.07,100.05,100.05,100.05,100.05,100.05,100.05,108.77,111.32,111.6,108.52,103.13,102.87,102.75,102.75,102.75,102.75,102.75,102.75,115.22,115.53,115.4,111.99,107.93,107.43,106.98,106.98,106.98,106.98,106.98,106.98,113.71,118.77,118.54,116.16,110.52,110.06,109.9,109.9,110.72,110.09,110.07,112.45,113.06,119.83,119.84,113.73,110.5,110.12,109.86,110.36,110.36,110.59,112.52,112.1,115.9,122.96,121.26,114.55,111.57,110.65,109.77,112.38,112.35,112.2,114.46,116.26,119.57,127.77,126.59,120.45,116.38,116.3,115.05) > 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/1g2ze1384774813.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/2nfve1384774813.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/3mik71384774813.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.259394047 -0.105256762 -0.230338559 -0.332157328 [6] -0.073227591 -0.006483065 -0.068240215 -0.265907447 -0.229866186 [11] -0.081807386 0.264810764 0.719652326 0.281399969 -0.093310942 [16] -0.232947120 -0.252877372 -0.051193266 -0.020620980 -0.047340973 [21] -0.212878449 -0.169238496 -0.057867373 0.251977106 0.536884216 [26] 0.257521573 -0.066654374 -0.259696577 -0.198733100 -0.040985813 [31] -0.023257504 -0.023229386 -0.121075180 -0.176580828 0.008133806 [36] 0.184681726 0.378787089 0.296694822 -0.068426860 -0.252106555 [41] -0.177550313 -0.028418106 -0.044807374 -0.009906056 -0.044395282 [46] -0.158466437 0.012201677 0.187899741 0.220016582 > (mypacf <- c(rpacf$acf)) [1] 0.2593940468 -0.1849890734 -0.1665190656 -0.2732772173 0.0315833514 [6] -0.1259852531 -0.1805051302 -0.4217831862 -0.3014055173 -0.4152688615 [11] -0.1808719015 0.4025173391 -0.0157466307 -0.1205665416 -0.1102876451 [16] 0.0466056626 -0.0040423157 -0.1285588337 -0.0562181313 -0.0541146651 [21] 0.0675794494 -0.0724919573 0.0036780137 -0.0465442544 0.0370436576 [26] 0.0003625673 -0.0973667196 -0.0265927100 -0.0168975824 -0.0219288895 [31] -0.0204182105 0.0827958424 -0.1138347117 0.1148139528 -0.1049717199 [36] -0.0331622551 0.1199668953 0.0033289301 0.0013275490 -0.0359962032 [41] 0.1349114611 -0.0780856659 0.0411024805 0.0468317267 0.0221256864 [46] 0.0102409263 0.1268369038 -0.1022554139 > 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/4u1x81384774813.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/550pq1384774813.tab") > > try(system("convert tmp/1g2ze1384774813.ps tmp/1g2ze1384774813.png",intern=TRUE)) character(0) > try(system("convert tmp/2nfve1384774813.ps tmp/2nfve1384774813.png",intern=TRUE)) character(0) > try(system("convert tmp/3mik71384774813.ps tmp/3mik71384774813.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.776 0.584 3.332