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(530.3,527.76,521.41,1601.93,1577.49,1551.43,1551.43,1516.88,1485.95,1438.22,1385.06,1329.49,1329.49,1276.16,1242.34,1181.59,1160.21,1135.18,1135.18,1084.96,1077.35,1061.13,1029.98,1013.08,1013.08,996.04,975.02,951.89,944.4,932.47,932.47,920.44,900.18,886.9,869.74,859.03,859.03,844.99,834.82,825.62,816.92,813.21,813.21,811.03,804.16,788.62,778.76,765.91,765.91,753.85,742.22,732.11,729.94,731.22,731.22,729.11,726.94,720.52,709.36,703.21) > 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/1jf2y1333573050.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/2buak1333573050.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/3pylt1333573050.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.8413884097 0.6859497440 0.5326939187 0.4796477006 [6] 0.4279409046 0.3773097333 0.3333246107 0.2952416950 0.2638976786 [11] 0.2256899388 0.1926186229 0.1601526132 0.1388122266 0.1158342246 [16] 0.0938554791 0.0648837694 0.0440778293 0.0208429114 -0.0008407648 [21] -0.0215755474 -0.0401416979 -0.0612334092 -0.0823473702 -0.1008800198 [26] -0.1156989818 -0.1311464285 -0.1460363959 -0.1635442831 -0.1789398755 [31] -0.1910619567 -0.2013528103 -0.2090723111 -0.2168039957 -0.2252469971 [36] -0.2317214937 -0.2367431577 -0.2407007973 -0.2437708300 -0.2458499807 [41] -0.2485282322 -0.2518124427 -0.2515212907 -0.2482253744 -0.2418697562 [46] -0.2323464926 -0.2211379958 -0.2063863169 -0.1873512028 -0.1662793201 [51] -0.1428592197 -0.1179450079 -0.0913507867 -0.0627515829 -0.0315967369 [56] 0.0009604657 0.0374079836 0.0764980802 0.0516143515 0.0260279711 > (mypacf <- c(rpacf$acf)) [1] 0.841388410 -0.075273213 -0.084591184 0.247666633 -0.041552059 [6] -0.045909397 0.083965439 -0.015299552 -0.012267251 -0.009169240 [11] -0.002872092 -0.015334130 0.010503785 -0.015980949 -0.015949426 [16] -0.029086267 0.004656791 -0.030308225 -0.027188178 -0.004403959 [21] -0.022840977 -0.039350282 -0.017453217 -0.017854072 -0.022055509 [26] -0.029173870 -0.020023217 -0.036004796 -0.025342705 -0.016066256 [31] -0.028349906 -0.019262795 -0.020672085 -0.033133096 -0.017355725 [36] -0.020554719 -0.026712553 -0.020460918 -0.021020047 -0.029844190 [41] -0.027617534 -0.012817232 -0.017067839 -0.016631751 -0.003679815 [46] -0.009525507 -0.001400067 0.011578677 0.003330202 0.011025556 [51] 0.017416059 0.014973626 0.022522463 0.030418766 0.029413880 [56] 0.044037507 0.047073358 -0.203417057 0.009279764 > 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/47xe81333573050.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/5x1zw1333573051.tab") > > try(system("convert tmp/1jf2y1333573050.ps tmp/1jf2y1333573050.png",intern=TRUE)) character(0) > try(system("convert tmp/2buak1333573050.ps tmp/2buak1333573050.png",intern=TRUE)) character(0) > try(system("convert tmp/3pylt1333573050.ps tmp/3pylt1333573050.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.040 0.217 1.251