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(98.01,99.2,100.7,106.41,107.51,107.1,99.75,98.96,107.26,107.11,107.2,107.65,104.78,105.56,107.95,107.11,107.47,107.06,99.71,99.6,107.19,107.26,113.24,113.52,110.48,111.41,115.5,118.32,118.42,117.5,110.23,109.19,118.41,118.3,116.1,114.11,113.41,114.33,116.61,123.64,123.77,123.39,116.03,114.95,123.4,123.53,114.45,114.26,114.35,112.77,115.31,114.93,116.38,115.07,105,103.43,114.52,115.04,117.16,115,116.22,112.92,116.56,114.32,113.22,111.56,103.87,102.85,112.27,112.76,118.55,122.73) > 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/11b6r1352799164.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/2ajyx1352799164.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/36yiw1352799164.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.065180859 -0.338538266 -0.136353901 -0.152695574 [6] 0.055469001 0.273432485 -0.012888516 -0.094045283 -0.137751214 [11] -0.336207363 0.051533230 0.625933892 0.066458430 -0.307903189 [16] -0.132638418 -0.136084322 0.101185326 0.247513390 0.119079537 [21] -0.104307594 -0.103797378 -0.269394171 0.042026884 0.380055626 [26] 0.013765659 -0.269777986 -0.158138610 -0.043241095 0.059189070 [31] 0.183661096 0.113389723 -0.130982424 -0.075802768 -0.118687945 [36] 0.006549649 0.373910005 0.020405374 -0.198780740 -0.066888009 [41] -0.022478308 -0.020967889 0.115471173 -0.008032949 -0.097570735 [46] -0.005294397 -0.087848416 0.003521009 0.265546362 > (mypacf <- c(rpacf$acf)) [1] 0.0651808590 -0.3442493693 -0.0959876892 -0.2905638354 -0.0097243739 [6] 0.1214105777 -0.0682072266 0.0312004080 -0.1472619740 -0.3638838625 [11] -0.0862715184 0.4473741086 -0.0246108626 -0.1412832663 -0.0114849014 [16] -0.0454044894 -0.0034048396 -0.0418234392 0.2500499977 -0.1155722770 [21] 0.0912954406 -0.0187650805 0.0433278361 -0.1483622148 -0.1100624774 [26] -0.0363779328 -0.1690442102 0.1290983025 -0.1366048292 0.0006904738 [31] -0.1283695927 -0.1085477502 0.0351125086 -0.0662867973 0.0080450141 [36] 0.0850204281 0.0134946911 0.0341884121 0.1141238657 -0.0307416770 [41] -0.0856286476 -0.0868637344 -0.1248388233 0.0810362785 0.0169383624 [46] 0.0488245020 -0.0531437981 -0.0604326468 > 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/4q7qq1352799164.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/525141352799164.tab") > > try(system("convert tmp/11b6r1352799164.ps tmp/11b6r1352799164.png",intern=TRUE)) character(0) > try(system("convert tmp/2ajyx1352799164.ps tmp/2ajyx1352799164.png",intern=TRUE)) character(0) > try(system("convert tmp/36yiw1352799164.ps tmp/36yiw1352799164.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.442 0.431 2.842