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(500,500.01,500.02,500.03,500.04,500.05,500.06,500.07,500.08,500.09,500.10,500.11,500.12,500.13,500.14,500.15,500.16,500.17,500.18,500.19,500.20,500.21,500.22,500.23,500.24,500.25,500.26,500.27,500.28,500.29,500.30,500.31,500.32,500.33,500.34,500.35,500.36,500.37,500.38,500.39,500.40,500.41,500.42,500.43,500.44,500.45,500.46,500.47,500.48,500.49,500.50,500.51,500.52,500.53,500.54,500.55,500.56,500.57,500.58,500.59,500.60,500.61,500.62,500.63,500.64,500.65,500.66,500.67,500.68,500.69,500.70,500.71) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1xfun1388342038.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/2voc41388342038.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/3utc31388342038.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.95833333 0.91669882 0.87512863 0.83365490 0.79230979 [7] 0.75112547 0.71013409 0.66936781 0.62885877 0.58863914 0.54874108 [13] 0.50919673 0.47003827 0.43129783 0.39300759 0.35519969 0.31790630 [19] 0.28115956 0.24499164 0.20943469 0.17452087 0.14028233 0.10675124 [25] 0.07395974 0.04194000 0.01072416 -0.01965560 -0.04916715 -0.07777831 [31] -0.10545694 -0.13217088 -0.15788797 -0.18257605 -0.20620297 -0.22873657 [37] -0.25014470 -0.27039520 -0.28945591 -0.30729468 -0.32387935 -0.33917776 [43] -0.35315776 -0.36578719 -0.37703389 -0.38686571 -0.39525050 -0.40215609 [49] -0.40755032 -0.41140105 -0.41367612 -0.41434337 -0.41337063 -0.41072577 [55] -0.40637662 -0.40029102 -0.39243681 -0.38278185 -0.37129397 -0.35794103 [61] -0.34269085 > (mypacf <- c(rpacf$acf)) [1] 0.9583333333 -0.0208825087 -0.0209333253 -0.0209854008 -0.0210383348 [6] -0.0210917062 -0.0211450713 -0.0211979613 -0.0212498796 -0.0213002993 [11] -0.0213486599 -0.0213943648 -0.0214367775 -0.0214752182 -0.0215089604 [16] -0.0215372266 -0.0215591843 -0.0215739416 -0.0215805424 -0.0215779619 [21] -0.0215651008 -0.0215407807 -0.0215037381 -0.0214526187 -0.0213859715 [26] -0.0213022427 -0.0211997698 -0.0210767753 -0.0209313604 -0.0207614995 [31] -0.0205650344 -0.0203396688 -0.0200829636 -0.0197923332 -0.0194650419 [36] -0.0190982021 -0.0186887733 -0.0182335630 -0.0177292294 -0.0171722856 [41] -0.0165591069 -0.0158859394 -0.0151489124 -0.0143440526 -0.0134673008 [46] -0.0125145318 -0.0114815754 -0.0103642389 -0.0091583312 -0.0078596843 [51] -0.0064641743 -0.0049677368 -0.0033663759 -0.0016561629 0.0001667784 [56] 0.0021063051 0.0041663115 0.0063508144 0.0086640757 0.0111107676 > 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/4176y1388342038.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/5g9bb1388342038.tab") > > try(system("convert tmp/1xfun1388342038.ps tmp/1xfun1388342038.png",intern=TRUE)) character(0) > try(system("convert tmp/2voc41388342038.ps tmp/2voc41388342038.png",intern=TRUE)) character(0) > try(system("convert tmp/3utc31388342038.ps tmp/3utc31388342038.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.400 0.463 2.838