R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(103.24,103.43,103.43,103.43,103.31,103.31,103.31,103.31,104.06,104.8,105.36,105.38,105.38,105.38,108.37,112.21,112.05,112.05,112.06,112.05,111.36,111.36,111.36,111.36,111.78,111.89,111.89,111.89,112.02,112.02,112.02,112.02,112.02,112.02,112.02,111.28,111.28,111.28,111.28,110.56,110.56,110.56,110.56,110.56,111.37,109.43,109.43,109.57,109.57,109.57,109.57,109.57,109.39,111.68,111.68,111.68,111.93,111.93,111.93,111.93,111.56,111.89,111.89,111.89,110.82,110.82,110.82,110.82,110.98,110.98,111.78,111.78) > 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/1gbnq1358279401.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/2e3n51358279401.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/3bzdw1358279401.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.2325397184 -0.0300141040 -0.0135775388 0.0314436275 [6] 0.0002608856 0.0725624336 0.0359532316 -0.1426048042 0.0583024822 [11] 0.0282526661 -0.1296252381 -0.0304458669 0.0047050966 -0.0200855971 [16] 0.0384797386 -0.0149380996 0.0405037972 -0.0525267371 0.0744141305 [21] -0.0954201005 -0.0803507488 -0.0086162235 -0.0016441678 -0.0876606979 [26] -0.0400784132 -0.0052083114 -0.0263422051 -0.0044006236 0.1169404378 [31] -0.1541803384 -0.1880074197 0.0114290934 -0.0425909593 -0.0040643560 [36] -0.0401888980 -0.0463166562 -0.0774333810 0.2009994609 0.1614835306 [41] -0.0282138477 0.0052042521 0.0001654955 0.0134993337 0.0359443466 [46] -0.0158803124 -0.0081769564 0.0059854351 -0.0169537956 > (mypacf <- c(rpacf$acf)) [1] 0.232539718 -0.088895843 0.015657937 0.030347140 -0.016825247 [6] 0.085756810 -0.003565264 -0.154276121 0.150621060 -0.051996111 [11] -0.134633147 0.062984810 -0.041135495 0.003502732 0.069377961 [16] -0.105955466 0.148371722 -0.110696196 0.070527053 -0.102955864 [21] -0.054113744 0.022622867 -0.011819416 -0.136103957 0.086532640 [26] -0.073656588 0.036085999 -0.009407264 0.104403142 -0.224270665 [31] -0.073090833 0.017285346 -0.063068514 0.006971853 -0.043859989 [36] -0.088818051 0.105025667 0.118742429 0.089021782 -0.023522463 [41] -0.020409614 -0.047638355 0.057183643 -0.102488925 0.008797735 [46] 0.002889714 0.021095979 -0.100980440 > 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/4ss3j1358279402.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/5jdur1358279402.tab") > > try(system("convert tmp/1gbnq1358279401.ps tmp/1gbnq1358279401.png",intern=TRUE)) character(0) > try(system("convert tmp/2e3n51358279401.ps tmp/2e3n51358279401.png",intern=TRUE)) character(0) > try(system("convert tmp/3bzdw1358279401.ps tmp/3bzdw1358279401.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.742 0.761 4.535