R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(11798,8378,8131,7676,7505,8168,6455,6141,6554,6888,5339,1624,9187,5047,5289,4169,3862,4253,3768,3066,4108,3890,3420,1221,5984,4064,5151,4027,3530,4819,3855,3584,4322,4154,4656,1464,7780,5060,6084,4778,4989,4903,4142,4101,4595,5034,5407,1782,8395,5291,6116,4210,4621,5299,4293,4542,3831,4360,4088,1508,6743,4159,5105,4283,4019,4206,3948,3407,3701,4159,4208,2622) > 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/wessaorg/rcomp/tmp/11n441413542461.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/2zr021413542461.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/3mx1z1413542461.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.225326322 0.389129276 0.273822620 0.312583584 [6] 0.263476814 0.064263032 0.158099858 0.147455178 0.051647286 [11] 0.058072147 -0.189580599 0.444166131 -0.171241846 -0.032160622 [16] -0.159792074 -0.096649172 -0.109276510 -0.233917668 -0.144292294 [21] -0.113716412 -0.155270082 -0.103280943 -0.271228750 0.258054615 [26] -0.172724428 -0.035450681 -0.119425038 -0.037933331 -0.042153400 [31] -0.124078744 -0.030771684 -0.012609744 -0.011948060 0.033708437 [36] -0.106689329 0.330886262 -0.006839331 0.068177214 0.003660249 [41] 0.068084843 0.047466271 -0.027128038 0.046926684 0.042777173 [46] 0.056995495 0.054393766 -0.061532237 0.241591294 > (mypacf <- c(rpacf$acf)) [1] 0.225326322 0.356455254 0.165428515 0.151842100 0.093625420 [6] -0.184739679 -0.029229672 0.083800640 -0.058516819 -0.009720558 [11] -0.280753849 0.593800816 -0.394540852 -0.236354173 -0.118814915 [16] -0.065579040 -0.058772553 0.128974358 0.025954705 -0.025405889 [21] -0.030453776 0.056677845 0.168209580 -0.063201346 -0.030463908 [26] -0.093116732 -0.015433681 -0.016742425 -0.001719573 -0.043293259 [31] 0.042387921 -0.061247493 0.112975261 0.082759508 -0.022518151 [36] 0.047963488 -0.028702451 -0.114314906 0.022097525 0.025458438 [41] -0.024135038 0.027441207 0.005028265 0.053002646 0.034612437 [46] -0.049495607 0.046024115 -0.152105928 > 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/4xdyx1413542461.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/5xvnl1413542461.tab") > > try(system("convert tmp/11n441413542461.ps tmp/11n441413542461.png",intern=TRUE)) character(0) > try(system("convert tmp/2zr021413542461.ps tmp/2zr021413542461.png",intern=TRUE)) character(0) > try(system("convert tmp/3mx1z1413542461.ps tmp/3mx1z1413542461.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.165 0.222 1.400