R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 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(-2,0,1,-3,-3,-5,-7,-7,-5,-13,-16,-20,-18,-21,-20,-16,-14,-12,-10,-3,-4,-4,-1,-8,-10,-11,-7,-2,-6,-4,0,2,2,5,8,8,5,10,6,6,9,5,5,-4,-5,-1,-8,-8,-13,-18,-8,-8,-6,-5,-11,-14,-12,-13,-19,-21,-22,-13,-21,-17,-15,-14,-11,-8,-3,-2,-1,1) > 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/163up1394796619.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/2oari1394796619.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/3guhh1394796619.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.8829063342 0.7869799516 0.6834497876 0.5508060465 [6] 0.4422751975 0.3042197561 0.1987030187 0.1035986665 0.0033566242 [11] -0.0155044070 -0.0430652601 -0.0891903000 -0.1075718135 -0.1305429968 [16] -0.1643375805 -0.2146412751 -0.2750148422 -0.3105904918 -0.3698680185 [21] -0.4462026762 -0.5050691876 -0.5557153948 -0.5495044983 -0.5461022058 [26] -0.5223546605 -0.4682604923 -0.4376626935 -0.3656893638 -0.2635064164 [31] -0.1638580627 -0.0721560031 0.0002283418 0.0732292095 0.1365712198 [36] 0.1543590446 0.1615289766 0.1705484770 0.1544275472 0.1361830388 [41] 0.1156779468 0.1017490980 0.1075489793 0.1097867288 0.1357263552 [46] 0.1507740786 0.1597935790 0.1707311504 0.1916015893 > (mypacf <- c(rpacf$acf)) [1] 0.8829063342 0.0338192952 -0.0805561637 -0.1994658219 0.0041622109 [6] -0.1916837057 0.0430742181 -0.0344071575 -0.0722626972 0.2463763667 [11] -0.0154230326 -0.1868436055 -0.0177564100 -0.0033321665 -0.1834379985 [16] -0.1250212787 -0.0874668481 0.0050045335 -0.0654987908 -0.1971034257 [21] -0.1640718957 -0.0085715474 0.2157393857 -0.1472654672 -0.0780551848 [26] 0.0651935732 -0.0821774040 0.0005858676 0.1271393386 0.0698659887 [31] -0.0051453496 0.0864258189 -0.0979554449 -0.0298877271 -0.0305734203 [36] -0.1767851549 -0.0323694936 0.0606550699 -0.0801675622 -0.1244431233 [41] 0.0212242234 0.0057541379 -0.0741042188 0.0078058183 -0.0801863220 [46] 0.0159478525 0.0076813716 -0.0005502713 > 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/42ri01394796619.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/5dz1x1394796619.tab") > > try(system("convert tmp/163up1394796619.ps tmp/163up1394796619.png",intern=TRUE)) character(0) > try(system("convert tmp/2oari1394796619.ps tmp/2oari1394796619.png",intern=TRUE)) character(0) > try(system("convert tmp/3guhh1394796619.ps tmp/3guhh1394796619.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.636 0.572 3.204