R version 2.13.0 (2011-04-13) Copyright (C) 2011 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(16.41,16.38,16.12,16.03,16.02,16.01,16.01,15.94,15.88,15.75,15.8,15.84,15.84,15.79,15.79,15.75,15.63,15.63,15.63,15.62,15.59,15.55,15.61,15.58,15.58,15.64,15.56,15.57,15.46,15.5,15.5,15.58,15.69,15.78,15.8,15.79,15.79,15.79,15.75,15.71,15.76,15.76,15.76,15.76,15.78,15.84,15.82,15.86,15.86,15.87,15.84,15.84,15.89,15.89,15.89,15.91,15.95,16.08,16.08,16.09) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > 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/1vpqr1333528657.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/2kmck1333528658.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/32ed31333528658.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.250127113 0.138546904 -0.014968331 0.021302744 [6] 0.094312240 -0.002914316 0.261180641 0.035527082 -0.043094054 [11] 0.077976164 0.136970574 0.167029344 0.109076523 0.153111010 [16] 0.030759657 -0.102504566 -0.067335802 -0.012656148 0.052959996 [21] -0.012252324 0.070457501 0.019646076 -0.007607408 0.005727742 [26] 0.050321258 0.122307180 -0.046656144 -0.077452767 -0.239487284 [31] -0.123023148 -0.218627733 -0.035269120 -0.018414451 0.009904243 [36] 0.035915960 -0.048767882 0.002022192 -0.109180081 -0.048303870 [41] -0.065203512 -0.074379110 -0.071263949 -0.113209652 -0.050435893 [46] -0.056186455 0.003642561 -0.008320306 -0.068847808 > (mypacf <- c(rpacf$acf)) [1] 0.250127113 0.081054384 -0.072038324 0.031653775 0.101299627 [6] -0.059996007 0.277633886 -0.087462095 -0.115187069 0.181561126 [11] 0.109394125 0.013154205 0.114439387 0.045226900 -0.072084114 [16] -0.066457162 -0.068034996 -0.049438245 0.052509473 -0.054716455 [21] 0.035801064 0.003963429 -0.008755638 -0.008874429 0.029855084 [26] 0.066289883 -0.075069113 -0.075704025 -0.207372792 0.022309999 [31] -0.208942504 0.034542421 -0.049842326 0.061361049 0.071031592 [36] 0.026962896 -0.042021148 -0.021949823 0.007021344 -0.044769259 [41] 0.052889617 0.012070477 -0.009319276 0.007653161 -0.038221314 [46] -0.005850205 -0.064537784 -0.072212247 > 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/4tfm21333528658.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/5ucl01333528658.tab") > > try(system("convert tmp/1vpqr1333528657.ps tmp/1vpqr1333528657.png",intern=TRUE)) character(0) > try(system("convert tmp/2kmck1333528658.ps tmp/2kmck1333528658.png",intern=TRUE)) character(0) > try(system("convert tmp/32ed31333528658.ps tmp/32ed31333528658.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.968 0.228 1.197