R version 2.12.0 (2010-10-15) Copyright (C) 2010 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(293403 + ,277108 + ,264020 + ,260646 + ,246100 + ,244051 + ,241329 + ,234730 + ,234509 + ,233482 + ,233406 + ,228548 + ,223914 + ,223696 + ,223004 + ,213765 + ,210554 + ,202204 + ,199512 + ,195304 + ,191467 + ,191381 + ,191276 + ,190410 + ,188967 + ,188780 + ,185139 + ,185039 + ,184217 + ,181853 + ,181379 + ,181344 + ,179562 + ,178863 + ,178140 + ,176789 + ,176460 + ,175877 + ,175568 + ,174107 + ,173587 + ,173260 + ,172684 + ,167845 + ,167131 + ,167105 + ,166790 + ,164767 + ,162810 + ,162336 + ,161678 + ,158980 + ,157250 + ,156833 + ,155383 + ,154991 + ,154730 + ,151503 + ,146455 + ,143937 + ,142339 + ,142146 + ,142141 + ,142069 + ,141933 + ,139350 + ,139144 + ,137793 + ,136911 + ,136548 + ,135171 + ,134043 + ,131876 + ,131122 + ,130539 + ,130533 + ,130232 + ,129100 + ,128655 + ,128066 + ,127619 + ,127324 + ,126683 + ,126681 + ,125971 + ,125366 + ,122433 + ,121135 + ,119291 + ,118958 + ,118807 + ,118372 + ,116900 + ,116775 + ,115199 + ,114928 + ,114397 + ,113337 + ,111664 + ,108715 + ,107342 + ,107335 + ,106539 + ,105615 + ,105410 + ,105324 + ,103012 + ,102531 + ,101324 + ,100885 + ,100672 + ,99946 + ,99768 + ,99246 + ,98599 + ,98030 + ,94763 + ,93340 + ,93125 + ,91185 + ,90961 + ,90938 + ,89318 + ,88817 + ,84944 + ,84572 + ,84256 + ,80953 + ,78800 + ,78776 + ,75812 + ,75426 + ,74398 + ,74112 + ,73567 + ,69471 + ,68948 + ,67746 + ,67507 + ,65029 + ,64320 + ,61857 + ,61499 + ,50999 + ,46660 + ,43287 + ,38214 + ,35523 + ,32750 + ,31414 + ,24188 + ,22938 + ,21054 + ,17547 + ,14688 + ,7199 + ,969 + ,455 + ,203 + ,98 + ,0 + ,0 + ,0 + ,0) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '1' > par3 = '1' > par2 = '0.2' > par1 = 'Default' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '1' > par3 <- '1' > par2 <- '0.2' > par1 <- 'Default' > #'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/www/rcomp/tmp/1hsx11346336867.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/www/rcomp/tmp/2a7tb1346336867.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/www/rcomp/tmp/3wkyh1346336867.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.2500181478 0.1058498647 0.1699852417 0.4523981932 [6] 0.1357641293 0.0479281837 0.0347065964 0.0446024966 0.0241968504 [11] 0.1321012734 0.0497775695 0.0479600780 0.0640287108 0.0469352534 [16] 0.0437926221 0.0207794491 0.0604395997 -0.0262964712 -0.0002311656 [21] -0.0196237019 0.0050047447 -0.0028498251 > (mypacf <- c(rpacf$acf)) [1] 0.25001815 0.04623062 0.14237054 0.41034017 -0.06760620 -0.02634834 [7] -0.07721020 -0.18062490 0.02124519 0.18324668 0.04482695 0.11928075 [13] 0.03247190 -0.16478231 -0.01982427 -0.07257045 0.03771928 0.04358570 [19] 0.03429305 -0.02696013 -0.03023232 -0.01535182 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/4frd91346336867.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/www/rcomp/tmp/5dd4u1346336867.tab") > > try(system("convert tmp/1hsx11346336867.ps tmp/1hsx11346336867.png",intern=TRUE)) character(0) > try(system("convert tmp/2a7tb1346336867.ps tmp/2a7tb1346336867.png",intern=TRUE)) character(0) > try(system("convert tmp/3wkyh1346336867.ps tmp/3wkyh1346336867.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.730 0.050 0.773