R version 3.0.1 (2013-05-16) -- "Good Sport" 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(12960,12480,13200,10560,13680,13440,14400,14880,16560,14400,13680,17040,14400,10800,12720,9600,13440,11040,14640,13200,13920,15600,15360,18240,13200,11040,12240,8880,12720,9840,13920,13200,11760,16800,15120,17280,12960,12000,10800,8880,11760,10560,14400,13920,12000,16080,14880,19200,15360,9360,9360,9360,11040,11040,14880,13680,12240,15360,14160,20400,16080,9360,9840,8160,11280,12960,16320,16080,12960,15120,13440,19200,14640,11760,10560,7920,11760,14160,16560,15600,11520,16560,12960,19920,16560,12000,11040,7440,11760,11280,17040,17040,12960,16800,12480,19440,16560,12240,9360,6480,12720,12240,16080,18480,13680,15360,11520,19920) > 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/wessaorg/rcomp/tmp/1s7uz1376905075.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/2stb51376905075.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/3cu491376905075.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.33666252 0.16905725 -0.23179385 -0.38278568 -0.13150358 [7] -0.33855635 -0.07743736 -0.35464083 -0.21790430 0.13326714 0.29163814 [13] 0.82222175 0.31966267 0.19079636 -0.21197686 -0.37862457 -0.12342631 [19] -0.30249947 -0.04399535 -0.27173381 -0.18108454 0.08735818 0.21648687 [25] 0.66566936 0.31637728 0.19246186 -0.18306308 -0.35035793 -0.14991405 [31] -0.27506762 -0.05108291 -0.20154335 -0.12951734 0.07878343 0.15858565 [37] 0.55652305 0.27727644 0.13592507 -0.14519105 -0.30542524 -0.16485147 [43] -0.27174131 -0.02770578 -0.12625996 -0.07366218 0.07088212 0.10835015 [49] 0.42218738 0.19793717 0.10538262 -0.09496374 -0.25937364 -0.12686896 [55] -0.24054939 -0.02264148 -0.09665344 -0.04412932 0.07720036 0.07354078 [61] 0.30658195 > (mypacf <- c(rpacf$acf)) [1] 0.3366625200 0.0628377260 -0.3468099810 -0.2792584176 0.2070775154 [6] -0.4057233028 -0.1042239048 -0.4443138213 -0.2861906880 0.1599923143 [11] 0.1236309808 0.5711319846 -0.0985783137 -0.0052052192 0.0266643309 [16] -0.0178759197 0.1219902719 0.0186797066 -0.0151450637 0.1667234885 [21] -0.0170565433 -0.0546636501 -0.0026287572 -0.0555075506 0.1294751677 [26] -0.0164481219 -0.0668764014 0.0585321512 -0.0891562689 -0.0038101261 [31] -0.1132885527 -0.0124983229 0.1104223723 0.0012648285 -0.0853685644 [36] 0.0758441358 -0.1524737457 -0.1350105920 0.0832805922 -0.0033492348 [41] -0.0178956788 -0.1002663283 0.0626248777 0.0569290046 -0.0273357416 [46] -0.1069759227 -0.0589075099 -0.0308325230 -0.0248515821 -0.0652199075 [51] 0.0238602293 0.0291128615 0.0505020154 -0.0475888338 -0.0682548452 [56] -0.0540206507 0.0055409235 0.0321102287 -0.0007550746 -0.1074378479 > 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/47roh1376905075.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/5qu0e1376905075.tab") > > try(system("convert tmp/1s7uz1376905075.ps tmp/1s7uz1376905075.png",intern=TRUE)) character(0) > try(system("convert tmp/2stb51376905075.ps tmp/2stb51376905075.png",intern=TRUE)) character(0) > try(system("convert tmp/3cu491376905075.ps tmp/3cu491376905075.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.443 0.555 3.101