R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 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(107.00,116.14,117.18,102.28,109.43,114.28,117.39,116.66,114.29,114.18,114.12,122.62,115.70,127.91,119.55,115.08,116.63,121.38,123.41,120.70,119.40,116.83,116.40,121.67,116.54,129.61,119.93,117.64,121.01,124.20,125.23,123.24,121.58,120.89,117.77,110.91,124.23,127.70,129.45,120.13,122.02,126.59,126.34,125.15,125.02,124.40,127.55,126.63,130.18,136.95,136.81,129.59,133.37,140.02,139.67,139.99,134.57,134.41,134.99,135.70) > 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/1sr4a1394703894.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/29fvd1394703894.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/31yfe1394703894.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.286521594 -0.174483156 -0.175059715 0.067250343 [6] 0.127799261 -0.013661538 0.059350033 -0.031083668 0.017885111 [11] -0.299015832 0.032502627 0.416552366 -0.045327566 -0.168537695 [16] -0.140215703 0.084142271 0.053648772 -0.005234045 0.072238209 [21] -0.062766417 0.064101877 -0.329165409 0.162626143 0.148435048 [26] 0.078436855 -0.191612729 0.028356287 -0.019001046 -0.030684757 [31] 0.057367711 0.012432409 0.129894696 -0.155095773 -0.163072176 [36] 0.059975817 0.193519585 0.029990174 -0.158954218 0.010342976 [41] 0.019290120 -0.007356124 0.075225915 -0.045649616 0.052154362 [46] -0.041078722 -0.082485524 0.013585294 0.139147588 > (mypacf <- c(rpacf$acf)) [1] -0.28652159 -0.27952531 -0.37712457 -0.27049158 -0.13690163 -0.14610820 [7] 0.03195006 0.09184092 0.18051582 -0.23549658 -0.32256051 0.16482463 [13] 0.09375967 0.00479615 0.04806790 0.06311262 -0.04939658 -0.13341039 [19] 0.04221367 -0.09126073 0.02052606 -0.16445368 -0.01991065 -0.12833174 [25] -0.06078868 -0.11154266 0.16002248 0.02304182 -0.06141114 -0.05217666 [31] -0.05546056 0.02729641 -0.10259399 -0.06828667 -0.08028390 -0.05042214 [37] -0.02883415 -0.08271195 -0.10493846 -0.04475348 0.01106525 0.14780623 [43] 0.03070605 -0.18334200 0.04132130 0.02708119 0.05488202 -0.01450239 > 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/40opu1394703894.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/565ak1394703894.tab") > > try(system("convert tmp/1sr4a1394703894.ps tmp/1sr4a1394703894.png",intern=TRUE)) character(0) > try(system("convert tmp/29fvd1394703894.ps tmp/29fvd1394703894.png",intern=TRUE)) character(0) > try(system("convert tmp/31yfe1394703894.ps tmp/31yfe1394703894.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.416 0.472 2.886