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(102.89,102.64,103.33,103.56,103.6,104.24,105.31,105.4,105.89,105.89,105.54,106.15,106.14,105.85,106.27,106.51,106.82,106.53,107.14,107.39,107.33,107.53,107.42,108.25,108.26,108.93,109.43,109.61,109.74,110.12,110.16,110.44,111.23,112.86,112.77,113.04,112.79,113.87,114.28,115.51,116.76,116.91,116.47,116.94,117.24,116.82,117.48,117.11,117.31,117.77,118.37,117.91,118.12,118.02,117.77,117.85,118.68,118.9,118.6,118.21,118.37,117.43,117.5,116.71,116.98,117.74,117.44,117.85,118.54,118.73,118.68,118.19) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > 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/1zs7z1358204637.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/26pq41358204637.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/3acrk1358204637.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.018157447 0.046169937 0.044705831 0.035147803 [6] -0.085867336 0.108347925 0.134731496 0.081873404 0.046549632 [11] 0.103076289 -0.049051973 0.078013538 -0.025715366 -0.063617925 [16] -0.065372077 0.042285697 0.118075837 -0.039155820 0.023229769 [21] -0.169330325 -0.044864881 -0.210286856 -0.062375602 -0.092002386 [26] 0.048716531 -0.119327815 0.048496832 -0.075958942 -0.034637100 [31] -0.123000698 -0.013977729 0.024033461 -0.014387830 0.005642349 [36] 0.124819552 -0.117249832 -0.004267582 -0.052891561 -0.062589142 [41] -0.076060986 0.082703635 0.047079051 -0.062407687 0.098553381 [46] -0.068829006 0.007605831 -0.025079332 -0.038621080 > (mypacf <- c(rpacf$acf)) [1] 0.018157447 0.045855363 0.043178325 0.031731365 -0.091341884 [6] 0.107635381 0.138725139 0.077080148 0.029536604 0.072367584 [11] -0.050232668 0.082279360 -0.046924018 -0.103496852 -0.084336493 [16] 0.004861609 0.136741539 -0.059596399 -0.016800590 -0.200537501 [21] 0.006374043 -0.175667264 -0.058737194 -0.116030962 0.043494936 [26] -0.087554846 0.087296215 -0.018853693 -0.001140172 -0.013005302 [31] 0.020151582 0.174360426 -0.034117884 0.044376418 0.096953516 [36] -0.073087085 0.012807326 -0.060898034 -0.054734732 -0.101268086 [41] 0.059313736 -0.052781948 -0.072272094 -0.050180576 -0.094072636 [46] 0.022752922 -0.006372092 -0.106793059 > 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/4dzkx1358204637.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/51ny41358204637.tab") > > try(system("convert tmp/1zs7z1358204637.ps tmp/1zs7z1358204637.png",intern=TRUE)) character(0) > try(system("convert tmp/26pq41358204637.ps tmp/26pq41358204637.png",intern=TRUE)) character(0) > try(system("convert tmp/3acrk1358204637.ps tmp/3acrk1358204637.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.950 0.310 2.277