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(100.44,100.47,100.49,100.52,100.47,100.48,100.48,100.53,100.62,100.89,100.97,101.01,101.02,100.92,100.93,100.98,101.07,101.1,101.11,101.19,101.31,101.52,101.61,101.65,101.66,101.56,101.75,101.83,101.98,102.06,102.07,102.1,102.42,102.91,103.14,103.23,103.23,102.91,103.11,103.14,103.26,103.3,103.32,103.44,103.54,103.98,104.24,104.29,104.29,103.98,103.98,103.89,103.86,103.88,103.88,104.31,104.41,104.8,104.89,104.9,104.9,104.54,104.67,104.87,105.04,105.09,105.1,105.46,105.83,106.27,106.46,106.52,106.53,105.96,106,106.15,106.32,106.41,106.41,106.81,106.99,107.35,107.53,107.56) > 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/19env1384762817.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/26iph1384762817.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/3of0l1384762817.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.00000000 0.96073916 0.91844535 0.87592802 0.83745711 0.80131855 [7] 0.76861913 0.73626133 0.70393879 0.67459398 0.64874438 0.62178637 [13] 0.58609040 0.54469249 0.50012229 0.45584904 0.41664718 0.38315067 [19] 0.35275262 0.32303430 0.29361165 0.26735691 0.24451441 0.22149590 [25] 0.19239993 0.15893303 0.12271179 0.08795302 0.05830602 0.03197638 [31] 0.01024464 -0.01168661 -0.03401518 -0.05396313 -0.07132150 -0.08866627 [37] -0.11070125 -0.13624223 -0.16565823 -0.19135033 -0.21202669 -0.23008288 [43] -0.24703940 -0.26403774 -0.28050054 -0.29499574 -0.30592399 -0.31387822 [49] -0.32647836 > (mypacf <- c(rpacf$acf)) [1] 0.960739158 -0.059422785 -0.023497401 0.030272200 0.005500513 [6] 0.022194679 -0.015204209 -0.016369497 0.024553033 0.027330042 [11] -0.032475143 -0.126551077 -0.083278788 -0.058522518 -0.029489824 [16] 0.025067209 0.030496772 0.008211591 -0.013359655 -0.021076144 [21] 0.014728341 0.023359302 -0.011721734 -0.079957545 -0.053764970 [26] -0.046051342 -0.019578098 0.012106580 -0.011893027 0.025641228 [31] -0.024504707 -0.032722193 0.001765371 0.006278705 -0.008985156 [36] -0.060804177 -0.041212961 -0.061500465 0.008901630 0.007556236 [41] -0.030865379 -0.021219061 -0.021445727 -0.019740737 -0.008112265 [46] 0.013851646 0.026466989 -0.059382566 > 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/4fgqg1384762817.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/5nqv91384762817.tab") > > try(system("convert tmp/19env1384762817.ps tmp/19env1384762817.png",intern=TRUE)) character(0) > try(system("convert tmp/26iph1384762817.ps tmp/26iph1384762817.png",intern=TRUE)) character(0) > try(system("convert tmp/3of0l1384762817.ps tmp/3of0l1384762817.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.837 0.575 3.377