R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(840,880,930,920,940,880,980,860,900,930,870,1000,870,860,930,980,1010,860,1140,880,800,900,900,1000,890,890,870,1000,1050,790,1160,830,730,950,980,910,840,860,880,1030,1060,770,1140,890,740,860,1050,840,810,830,920,1070,1040,740,1250,850,790,810,1080,760,840,820,900,1010,1080,780,1150,820,790,820,1130,800,890,810,950,1090,1090,850,1200,790,800,850,1230,800,930,700,1030,1040,1000,830,1190,720,810,870,1190,800,970,690,1010,1030,950,830,1150,750,840,880,1210,830) > 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/1n3s51344780049.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/2vmoc1344780049.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/3fd0n1344780049.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.30308907 -0.08147904 -0.14956224 0.24194876 -0.27941544 [7] 0.19421824 -0.21697723 0.19393352 -0.15760911 -0.06417299 -0.24305197 [13] 0.85182757 -0.28899501 -0.07594579 -0.13958674 0.22067783 -0.25963929 [19] 0.14107179 -0.16854426 0.15316919 -0.11705696 -0.08371140 -0.15332761 [25] 0.68178590 -0.25612825 -0.05499087 -0.10447646 0.19412383 -0.22237303 [31] 0.10714796 -0.11414824 0.11899699 -0.08435307 -0.10523681 -0.07263841 [37] 0.51888807 -0.21245106 -0.05058345 -0.08260947 0.16549529 -0.18274516 [43] 0.08590961 -0.08402786 0.07930353 -0.05480274 -0.11122859 -0.01445569 [49] 0.37581955 > (mypacf <- c(rpacf$acf)) [1] -0.303089069 -0.190876508 -0.270640512 0.092112731 -0.268430077 [6] 0.058511443 -0.231763417 0.014718822 -0.110567232 -0.337895059 [11] -0.450367095 0.718507523 0.135730824 0.079158467 -0.004796446 [16] -0.208919612 0.116069729 -0.207708694 -0.096619962 -0.081185891 [21] 0.042743245 -0.018663708 0.066687120 -0.152781595 -0.066883679 [26] 0.075502542 -0.015188129 0.102715251 -0.001001569 0.056224748 [31] 0.123662689 0.015402110 -0.041849128 -0.066059603 -0.026558957 [36] -0.072841468 0.004795235 -0.093028926 -0.082241339 0.007324201 [41] -0.023276905 0.066225502 -0.033918835 -0.082785073 0.036793270 [46] 0.046109583 0.016742383 -0.038068017 > 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/4ehrd1344780049.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/5gctl1344780049.tab") > > try(system("convert tmp/1n3s51344780049.ps tmp/1n3s51344780049.png",intern=TRUE)) character(0) > try(system("convert tmp/2vmoc1344780049.ps tmp/2vmoc1344780049.png",intern=TRUE)) character(0) > try(system("convert tmp/3fd0n1344780049.ps tmp/3fd0n1344780049.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.385 0.281 1.656