R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 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(8.5,8.5,8.5,8.6,8.6,8.4,8.2,8,8,8,8,7.9,7.9,7.9,7.9,8,7.9,7.4,7.2,7,6.9,7.1,7.2,7.2,7.1,6.9,6.8,6.8,6.8,6.9,7.1,7.2,7.2,7.1,7.1,7.2,7.5,7.7,7.8,7.7,7.7,7.8,8,8.1,8.1,8,8.1,8.2,8.4,8.5,8.5,8.5,8.5,8.5,8.4,8.3,8.2,8.1,7.9,7.6,7.3,7.1,7,7.1,7.1,7.1,7.3,7.3,7.3,7.2,7.2,7.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/144ik1363355983.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/2oz0j1363355983.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/3ryqp1363355983.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.94748842 0.86162871 0.76245933 0.66447304 0.57269792 [7] 0.48461993 0.38441536 0.28125308 0.17276693 0.06080548 -0.04812432 [13] -0.14869861 -0.24195258 -0.32478064 -0.40065809 -0.47845805 -0.54561027 [19] -0.58407276 -0.60249680 -0.60480134 -0.59993345 -0.59831904 -0.59234201 [25] -0.57209406 -0.53476536 -0.47946860 -0.42047471 -0.36066746 -0.30086020 [31] -0.23661639 -0.17192892 -0.10058661 -0.02480775 0.05540767 0.12815489 [37] 0.19032831 0.23253722 0.26491176 0.29277581 0.32463275 0.35294045 [43] 0.37104407 0.36918318 0.35312531 0.33085626 0.30733018 0.28454353 [49] 0.26419698 > (mypacf <- c(rpacf$acf)) [1] 0.947488416 -0.353056671 -0.085304553 0.008547070 -0.008895824 [6] -0.060557574 -0.216818138 -0.023413915 -0.117085552 -0.119406968 [11] -0.066775232 -0.047449462 -0.068837015 -0.058236405 -0.084658170 [16] -0.178216032 0.001319522 0.147011985 -0.061571155 -0.058776585 [21] -0.079077708 -0.112068280 -0.027319866 0.005410716 0.033772933 [26] 0.002020713 -0.140516355 -0.027299352 -0.028951912 0.028307794 [31] -0.025860041 0.026355043 -0.023572828 0.028542618 -0.048328766 [36] -0.034328010 -0.092015705 -0.005204564 -0.033815456 0.033681556 [41] -0.044048212 -0.030671846 -0.079745120 -0.063658503 0.008838303 [46] -0.014816968 0.006570283 0.033807403 > 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/4g8cg1363355983.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/5j8ki1363355983.tab") > > try(system("convert tmp/144ik1363355983.ps tmp/144ik1363355983.png",intern=TRUE)) character(0) > try(system("convert tmp/2oz0j1363355983.ps tmp/2oz0j1363355983.png",intern=TRUE)) character(0) > try(system("convert tmp/3ryqp1363355983.ps tmp/3ryqp1363355983.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.825 0.277 2.096