R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" 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(3.875,3.863,3.876,3.878,3.881,3.883,3.884,3.885,3.895,3.903,3.911,3.929,3.946,3.965,3.992,4.010,4.015,4.020,4.037,4.059,4.083,4.102,4.126,4.145,4.162,4.169,4.178,4.174,4.168,4.170,4.159,4.159,4.143,4.159,4.167,4.176,4.185,4.195,4.210,4.226,4.250,4.259,4.270,4.277,4.286,4.303,4.320,4.336,4.352,4.371,4.392,4.415,4.442,4.457,4.472,4.474,4.461,4.453,4.446,4.450,4.459,4.474,4.492,4.509,4.526,4.541,4.550,4.562,4.555,4.554,4.551,4.553) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/108sx1384334187.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/2x0lx1384334187.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/3fjkc1384334187.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.965508833 0.926899985 0.886352842 0.843558698 [6] 0.798390325 0.752831212 0.706756828 0.660787673 0.616165841 [11] 0.572467399 0.529762258 0.488546290 0.448106658 0.408309343 [16] 0.368960908 0.329177703 0.287437005 0.245370484 0.205465307 [21] 0.168195326 0.134862474 0.104568570 0.077585915 0.053179367 [26] 0.030624653 0.008745572 -0.012349119 -0.033926593 -0.056803010 [31] -0.080354596 -0.105220891 -0.130586912 -0.156264934 -0.179720787 [36] -0.201725969 -0.222523256 -0.242358114 -0.261154347 -0.278727742 [41] -0.294176656 -0.309887799 -0.325723846 -0.342371649 -0.358904920 [46] -0.375697994 -0.391703331 -0.405656453 -0.417863137 -0.427364341 [51] -0.433705582 -0.436220121 -0.435147879 -0.429630935 -0.420903536 [56] -0.409303627 -0.397231222 -0.386094276 -0.374159844 -0.360444762 [61] -0.344619487 > (mypacf <- c(rpacf$acf)) [1] 0.9655088333 -0.0782875312 -0.0452949578 -0.0518845898 -0.0545135395 [6] -0.0260376992 -0.0310711667 -0.0228543979 -0.0064048201 -0.0155080999 [11] -0.0148389754 -0.0087936319 -0.0207197124 -0.0218721072 -0.0251614771 [16] -0.0382891131 -0.0599234565 -0.0349211032 0.0007801793 0.0063064218 [21] 0.0250245037 0.0082825694 0.0120342179 0.0001150315 -0.0108715133 [26] -0.0259968242 -0.0216254727 -0.0385580568 -0.0467682588 -0.0348942177 [31] -0.0440913468 -0.0298060916 -0.0286709213 0.0063705037 -0.0109805259 [36] -0.0182975059 -0.0251312670 -0.0246773422 -0.0203016689 -0.0047457975 [41] -0.0378976154 -0.0312962682 -0.0412637706 -0.0262532493 -0.0311239499 [46] -0.0184931488 -0.0019306333 -0.0110951769 -0.0005208836 0.0017076903 [51] 0.0111614870 0.0110174804 0.0276689706 0.0137147617 0.0129825158 [56] -0.0194813531 -0.0345309288 -0.0022169975 0.0140373634 0.0226688695 > 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/44xcf1384334187.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/5it6b1384334187.tab") > > try(system("convert tmp/108sx1384334187.ps tmp/108sx1384334187.png",intern=TRUE)) character(0) > try(system("convert tmp/2x0lx1384334187.ps tmp/2x0lx1384334187.png",intern=TRUE)) character(0) > try(system("convert tmp/3fjkc1384334187.ps tmp/3fjkc1384334187.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.782 0.369 2.125