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(31.5,31.29,31.3,31.06,31.09,31.11,31.13,31.1,31.03,30.74,30.83,30.82,30.8,30.74,30.71,30.58,30.71,30.7,30.7,30.72,30.68,30.78,30.84,30.8,30.8,30.88,30.87,30.92,30.82,30.75,30.75,30.75,30.63,30.52,30.58,30.6,30.6,30.63,30.56,30.61,30.53,30.6,30.6,30.63,30.66,30.34,30.32,30.3,30.3,30.08,29.96,29.91,29.83,29.89,29.85,30.06,29.83,29.95,30.02,30.03,30.03,29.96,29.85,30.12,29.91,29.9,29.92,29.89,29.96,29.72,29.6,29.54,29.54,29.54,29.48,29.55,29.58,29.6,29.6,29.56,29.7,29.76,29.24,29.28) > 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/fisher/rcomp/tmp/1yzc11386008794.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/fisher/rcomp/tmp/2n8zy1386008794.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/fisher/rcomp/tmp/3an6g1386008794.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.92626715 0.86850727 0.83123423 0.80183106 0.76318779 [7] 0.71810354 0.67143589 0.63114069 0.58834482 0.55781455 0.52768632 [13] 0.49780180 0.46667729 0.43613945 0.41396838 0.40803275 0.39357424 [19] 0.37562969 0.35399247 0.33463898 0.31939241 0.28452852 0.25074852 [25] 0.22146451 0.19154900 0.15837110 0.11842017 0.07610520 0.04869895 [31] 0.01567441 -0.01630423 -0.05127768 -0.08150355 -0.10875556 -0.13355404 [37] -0.14506955 -0.16270039 -0.19199604 -0.21731078 -0.23190796 -0.24166079 [43] -0.26019872 -0.28431827 -0.31116636 -0.33883757 -0.35284647 -0.36206457 [49] -0.37617532 -0.38601227 -0.39032986 -0.39330792 -0.38985257 -0.37473808 [55] -0.36771462 -0.35528764 -0.35239830 -0.33525065 -0.32380176 -0.31649457 [61] -0.31510409 > (mypacf <- c(rpacf$acf)) [1] 0.926267154 0.074184945 0.125516873 0.068592177 -0.044591721 [6] -0.058317837 -0.056210592 -0.005653481 -0.045069294 0.068588596 [11] 0.008345709 0.008566851 -0.011045185 -0.020982323 0.032775746 [16] 0.107809037 -0.019685957 -0.007433313 -0.038390310 -0.030272003 [21] -0.001950135 -0.153365941 -0.032874276 -0.021064796 -0.018568710 [26] -0.033883073 -0.069054050 -0.066442981 0.049405233 -0.039217487 [31] -0.010466000 -0.052275267 -0.015006955 -0.021286265 -0.013717666 [36] 0.072376763 -0.079268350 -0.075582673 -0.030087801 0.022013944 [41] 0.008134353 -0.068841174 -0.033568773 -0.053883140 -0.071420642 [46] 0.052063996 0.014380310 -0.002643183 0.056784814 0.021917536 [51] 0.018334958 0.014120012 0.088373034 -0.039027133 0.064935255 [56] -0.068437998 0.045557172 -0.046521607 -0.019640452 -0.056308425 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4qe9w1386008794.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/fisher/rcomp/tmp/5vyec1386008794.tab") > > try(system("convert tmp/1yzc11386008794.ps tmp/1yzc11386008794.png",intern=TRUE)) character(0) > try(system("convert tmp/2n8zy1386008794.ps tmp/2n8zy1386008794.png",intern=TRUE)) character(0) > try(system("convert tmp/3an6g1386008794.ps tmp/3an6g1386008794.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.377 0.726 4.079