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(58896,57616,56232,53708,79784,78524,58896,45848,47112,47112,48372,51040,54968,53708,45848,47112,83716,91572,70664,58896,61548,62828,69404,75856,77260,64088,65476,48372,96888,111200,78524,68016,74596,82452,94220,108656,108656,99412,95484,71928,111200,129564,113848,96888,99412,108656,121704,137420,126896,120444,120444,99412,129564,149188,133492,116516,121704,142612,151856,164888,154380,137420,133492,102080,122968,145260,120444,106008,120444,134756,142612,163624,153120,126896,129564,104744,125636,144000,122968,108656,121704,137420,134756,166168,160976,140068,141332,113848,130824,157048,137420,125636,145260,157048,147928,189724,179340,155784,149188,119056,136140,151856,132212,132212,154380,166168,159696,205420,193652,171484,162240,129564,141332,162240,146524,142612,160976,176672,159696,200228) > 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/fisher/rcomp/tmp/1s4n61377043295.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/2gkvi1377043296.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/3t1gj1377043296.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.869396355 0.765539085 0.723450705 0.686949367 [6] 0.704136048 0.723788230 0.677776982 0.627205691 0.627467162 [11] 0.613786160 0.664012467 0.722977855 0.600400670 0.494967815 [16] 0.447246090 0.409723743 0.423483667 0.448344992 0.407335285 [21] 0.348752014 0.341368378 0.322110179 0.360383910 0.412417101 [26] 0.311733435 0.216806392 0.175290171 0.141318082 0.155547982 [31] 0.182204898 0.146261332 0.088257549 0.080104571 0.064592140 [36] 0.096859375 0.147773907 0.079504568 0.006880313 -0.021283048 [41] -0.041527748 -0.026787153 0.003505836 -0.015819940 -0.069876968 [46] -0.074759591 -0.081933478 -0.051566000 -0.004119870 > (mypacf <- c(rpacf$acf)) [1] 0.869396355 0.039684876 0.204313070 0.048745264 0.279621020 [6] 0.120374603 -0.114177661 -0.029160126 0.167294404 -0.022763207 [11] 0.294578494 0.151091497 -0.593768938 -0.118956089 -0.003852161 [16] -0.027314997 0.010667371 0.048608135 0.022845837 -0.089413176 [21] 0.057896780 0.061446528 0.020175641 0.106689132 -0.129249006 [26] -0.076162111 -0.020822664 -0.065233420 -0.012681898 -0.060622844 [31] 0.004668318 -0.024694199 0.005350125 0.062643750 -0.017711042 [36] 0.056508017 0.085165198 0.002619203 0.009277281 -0.006580197 [41] -0.063246881 -0.059173508 0.037452326 -0.074516397 -0.028465120 [46] 0.019111784 -0.011511625 -0.048798233 > 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/4jsw71377043296.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/5idzm1377043296.tab") > > try(system("convert tmp/1s4n61377043295.ps tmp/1s4n61377043295.png",intern=TRUE)) character(0) > try(system("convert tmp/2gkvi1377043296.ps tmp/2gkvi1377043296.png",intern=TRUE)) character(0) > try(system("convert tmp/3t1gj1377043296.ps tmp/3t1gj1377043296.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.725 0.368 2.084