R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(0.68,0.68,0.69,0.69,0.7,0.7,0.7,0.7,0.7,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.76,0.77,0.78,0.85,0.89,0.9,0.91,0.91,0.91,0.9,0.89,0.88,0.87,0.86,0.87,0.87,0.87,0.85,0.84,0.84,0.84,0.84,0.84,0.82,0.87,0.92,0.92,0.92,0.93,0.94,0.87,0.84,0.83,0.81,0.81,0.81,0.8,0.8,0.8,0.8,0.8,0.8,0.79,0.8,0.8,0.8,0.81,0.83,0.83,0.83,0.83,0.82,0.82,0.82) > 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/16abf1352710791.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/2t92o1352710791.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/3e23h1352710791.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.94773952 0.87293498 0.79551038 0.70147287 0.60351965 [7] 0.51308112 0.43559894 0.36724378 0.30720949 0.25517934 0.20340832 [13] 0.15373911 0.10507761 0.05848913 0.01501017 -0.02432275 -0.05847313 [19] -0.08718185 -0.10336609 -0.12346603 -0.14748167 -0.16890604 -0.19228825 [25] -0.21656302 -0.24650978 -0.28290593 -0.31020385 -0.32296185 -0.33180416 [31] -0.33658682 -0.32849949 -0.31888620 -0.30256440 -0.28313307 -0.26396087 [37] -0.25043188 -0.23819852 -0.22524537 -0.21281047 -0.19882081 -0.18713450 [43] -0.18448885 -0.16595007 -0.13644158 -0.10955315 -0.08269351 -0.05197576 [49] -0.01817728 > (mypacf <- c(rpacf$acf)) [1] 0.9477395166 -0.2483078614 -0.0199158005 -0.2165412147 -0.0270596411 [6] 0.0137956936 0.0755366186 -0.0025986539 -0.0065036991 -0.0287403243 [11] -0.0845740195 -0.0226772521 -0.0459156531 -0.0003228662 -0.0131883242 [16] -0.0023482646 -0.0134581491 -0.0091090336 0.0674436875 -0.1361344423 [21] -0.0481616050 -0.0385666075 -0.0334881680 -0.0079459216 -0.0925820297 [26] -0.0994889651 0.0570911114 0.0884421777 -0.0426227892 -0.0242185737 [31] 0.0258204634 -0.0758637425 0.0801731934 -0.0324815118 0.0049663459 [36] -0.0844419272 0.0149230681 -0.0398541136 0.0167255590 0.0200251991 [41] -0.0735476576 -0.1087642134 0.1814222145 0.0553723900 0.0201717279 [46] -0.0277789897 -0.0315168150 0.0297812868 > 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/4p0o21352710791.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/5eezl1352710791.tab") > > try(system("convert tmp/16abf1352710791.ps tmp/16abf1352710791.png",intern=TRUE)) character(0) > try(system("convert tmp/2t92o1352710791.ps tmp/2t92o1352710791.png",intern=TRUE)) character(0) > try(system("convert tmp/3e23h1352710791.ps tmp/3e23h1352710791.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.886 0.412 2.277