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(2.79,3.08,3.89,3.7,4.61,5.07,5.22,4.93,5.15,4.8,3.89,3.54,3.34,2.8,1.6,1.53,0.69,-0.11,-0.67,-0.2,-0.62,-0.58,-0.31,-0.25,-0.08,0.13,0.94,1.05,1.59,2.03,2.15,2.06,2.56,2.55,2.53,2.6,2.71,2.82,2.93,2.88,2.89,3.27,3.32,3.14,3.04,3.08,3.39,3.23,3.38,3.41,3.14,2.96,2.73,2.21,2.23,2.56,2.39,2.49,2.17,2.16,1.48,1.09,1.25,1.26,1.39,1.69,1.55,1.19,1.08,0.93,0.98,1.01) > 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/1i56q1395070681.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/2h1i41395070681.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/3neku1395070681.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.958591046 0.892346945 0.799829190 0.683152638 [6] 0.541217494 0.405479110 0.266127924 0.112088906 -0.035453716 [11] -0.169427798 -0.289146550 -0.393652499 -0.453566889 -0.499301399 [16] -0.523784504 -0.532326551 -0.520563526 -0.508781288 -0.486546809 [21] -0.452842806 -0.416465104 -0.375373651 -0.334225990 -0.292349400 [26] -0.255353328 -0.214887757 -0.179566020 -0.145680734 -0.109209999 [31] -0.070979155 -0.034059855 0.004771666 0.048979025 0.088357461 [36] 0.129368653 0.169991735 0.200903856 0.225667773 0.249885281 [41] 0.272279269 0.282528845 0.293776181 0.298526727 0.292710930 [46] 0.272595495 0.253079302 0.220784572 0.183871206 > (mypacf <- c(rpacf$acf)) [1] 0.958591046 -0.327358820 -0.300844628 -0.255921546 -0.294654432 [6] 0.204162624 -0.050401515 -0.373298811 -0.026843964 0.008825277 [11] 0.128324004 0.050680156 0.259360560 -0.294562885 -0.052558880 [16] -0.104430737 -0.086416489 -0.056268938 -0.117885235 -0.172085101 [21] -0.050673652 0.128912530 -0.077685147 -0.052189198 0.148092013 [26] -0.097515472 -0.020855284 -0.107574690 0.006579464 -0.101231224 [31] 0.063783025 -0.052092497 -0.010713514 0.019757008 0.003610526 [36] 0.015215404 -0.179644695 0.047096946 -0.001495776 0.102327876 [41] -0.009329368 -0.030334617 -0.055299535 -0.030092671 0.027306570 [46] 0.003603969 -0.120439297 0.005884614 > 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/4ofe71395070681.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/5171g1395070681.tab") > > try(system("convert tmp/1i56q1395070681.ps tmp/1i56q1395070681.png",intern=TRUE)) character(0) > try(system("convert tmp/2h1i41395070681.ps tmp/2h1i41395070681.png",intern=TRUE)) character(0) > try(system("convert tmp/3neku1395070681.ps tmp/3neku1395070681.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.932 0.562 3.492