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(31566,30111,30019,31934,25826,26835,20205,17789,20520,22518,15572,11509,25447,24090,27786,26195,20516,22759,19028,16971,20036,22485,18730,14538,27561,25985,34670,32066,27186,29586,21359,21553,19573,24256,22380,16167,27297,28287,33474,28229,28785,25597,18130,20198,22849,23118,21925,20801,18785,20659,29367,23992,20645,22356,17902,15879,16963,21035,17988,10437,24470,22237,27053,26419,22311,20624,17336,15586,17733,19231,16102,11770) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/12l2t1413642183.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/2vsvh1413642183.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/37nyh1413642183.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.5345158101 0.3022268005 0.1406425120 -0.0480144099 [6] -0.1150909389 -0.2452983897 -0.1418388406 -0.1906394845 -0.0482705918 [11] 0.1017449052 0.2526157647 0.5571439626 0.2892288875 0.1126170362 [16] -0.0936528069 -0.1749780279 -0.1995727711 -0.3323104434 -0.2284744752 [21] -0.2225718877 -0.1276037938 0.0018260481 0.1661008287 0.3997394720 [26] 0.2189362470 0.1201931258 -0.0877242955 -0.1693143529 -0.1850106567 [31] -0.3084323386 -0.2017878466 -0.1658063806 -0.0821510979 0.0095124967 [36] 0.1423863757 0.3394673483 0.1991880664 0.1197336921 -0.0199010583 [41] -0.0967780504 -0.1147063696 -0.1669759013 -0.1166455655 -0.1066025626 [46] -0.0441924314 0.0009593543 0.0669598499 0.2215355063 > (mypacf <- c(rpacf$acf)) [1] 0.534515810 0.023127278 -0.041361317 -0.158546714 -0.036552963 [6] -0.184938734 0.129884105 -0.168361016 0.180977401 0.071924593 [11] 0.245423437 0.402853219 -0.348870828 -0.184722091 -0.267337092 [16] 0.086223410 0.055814236 -0.040656341 -0.037766455 0.080843098 [21] -0.084609596 0.017167561 -0.005988098 0.063551296 -0.039101987 [26] 0.043755174 -0.099812189 -0.028885011 -0.064407671 -0.045399506 [31] 0.091914646 0.077420616 -0.015112805 -0.037770538 -0.059325637 [36] 0.002082385 -0.029739619 -0.021001735 0.129389024 0.011979822 [41] 0.054897212 0.066158101 -0.141589729 -0.046210260 -0.067700904 [46] -0.012057134 0.009291056 0.006994721 > 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/40k4s1413642183.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/5z8li1413642183.tab") > > try(system("convert tmp/12l2t1413642183.ps tmp/12l2t1413642183.png",intern=TRUE)) character(0) > try(system("convert tmp/2vsvh1413642183.ps tmp/2vsvh1413642183.png",intern=TRUE)) character(0) > try(system("convert tmp/37nyh1413642183.ps tmp/37nyh1413642183.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.208 0.196 1.414