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(96.24,95.56,95.56,95.56,95.96,95.96,95.96,95.96,95.61,95.30,95.68,97.94,97.32,97.32,97.45,98.08,98.25,98.25,97.95,97.81,97.68,98.03,98.03,98.03,98.11,98.11,98.11,97.95,97.95,97.95,97.95,97.95,97.95,97.89,97.16,97.16,97.16,97.18,97.18,96.47,97.47,97.47,97.47,97.47,96.63,96.78,96.25,96.25,96.28,95.62,95.62,96.85,96.85,96.85,96.85,96.85,96.85,96.85,96.75,97.15,98.28,98.28,98.28,98.51,98.51,98.51,96.03,96.03,96.77,96.92,96.92,96.92) > 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/1bek31352710955.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/2hi981352710955.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/3d0741352710955.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.817480347 0.636957831 0.517161731 0.423585147 [6] 0.326422920 0.199669111 0.143636569 0.111457397 0.053368238 [11] -0.020428399 -0.091120394 -0.149719387 -0.218369467 -0.277205142 [16] -0.316213325 -0.298166756 -0.259578928 -0.254193339 -0.247832191 [21] -0.243374998 -0.269845744 -0.277231122 -0.315409344 -0.318308753 [26] -0.298476333 -0.282431580 -0.221835810 -0.203353973 -0.152566402 [31] -0.118005309 -0.093702196 -0.064123158 -0.067673799 -0.035610990 [36] -0.004110621 0.047306700 0.077527519 0.095786518 0.127912914 [41] 0.165459497 0.175814919 0.179952655 0.202843126 0.223743525 [46] 0.225574404 0.231350388 0.219955173 0.197511449 > (mypacf <- c(rpacf$acf)) [1] 0.817480347 -0.094404109 0.074454776 -0.003168566 -0.057305583 [6] -0.145419232 0.124730861 -0.016080361 -0.085003481 -0.075003682 [11] -0.064617565 -0.090304226 -0.094038728 -0.035156559 -0.050904759 [16] 0.086519240 0.027968209 -0.082597962 -0.020631212 -0.055285815 [21] -0.164887662 0.029413187 -0.153399277 -0.002574204 -0.031948398 [26] -0.044545719 0.063255689 -0.136772848 0.086926016 -0.078138391 [31] 0.016345877 -0.016073089 -0.103143043 0.032275608 -0.034284552 [36] 0.031038812 -0.068663485 -0.007736603 -0.005284165 0.079371765 [41] -0.072726739 0.067316617 0.045636164 -0.030522005 0.016935617 [46] 0.024230479 -0.085518240 -0.016835152 > 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/4t0181352710955.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/5puad1352710955.tab") > > try(system("convert tmp/1bek31352710955.ps tmp/1bek31352710955.png",intern=TRUE)) character(0) > try(system("convert tmp/2hi981352710955.ps tmp/2hi981352710955.png",intern=TRUE)) character(0) > try(system("convert tmp/3d0741352710955.ps tmp/3d0741352710955.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.099 0.432 2.522