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.98,0.99,0.99,0.99,1,1,1,1,1,1.01,1.02,1.02,1.01,1.03,1.03,1.03,1.03,1.03,1.03,1.03,1.04,1.06,1.07,1.08,1.08,1.09,1.09,1.09,1.1,1.1,1.1,1.1,1.1,1.11,1.12,1.13,1.13,1.13,1.13,1.13,1.14,1.14,1.14,1.14,1.14,1.14,1.15,1.15,1.15,1.15,1.15,1.15,1.16,1.15,1.16,1.16,1.16,1.17,1.17,1.17,1.18,1.19,1.2,1.21,1.21,1.21,1.21,1.22,1.22,1.22,1.23,1.22) > 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/1c8f31352710563.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/2cxhb1352710563.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/3is4m1352710563.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.956956364 0.912728947 0.869626122 0.824126139 [6] 0.780964125 0.738660353 0.693959423 0.647394035 0.598964191 [11] 0.555595015 0.517286508 0.480635296 0.439840847 0.403988688 [16] 0.367071126 0.331278156 0.294686133 0.257028707 0.220762224 [21] 0.180174937 0.144381967 0.113531288 0.085018579 0.059110190 [26] 0.031070994 0.005636119 -0.018141462 -0.044049850 -0.066821216 [31] -0.091190688 -0.116625563 -0.142859492 -0.167169774 -0.189674789 [36] -0.209841834 -0.227670909 -0.246831739 -0.264068922 -0.278849758 [41] -0.292772352 -0.303824274 -0.316740653 -0.331255138 -0.345769623 [46] -0.358094111 -0.371217652 -0.381204170 -0.389533393 > (mypacf <- c(rpacf$acf)) [1] 0.956956364 -0.036048604 -0.009569897 -0.051916052 0.003865919 [6] -0.015568350 -0.051649869 -0.049179968 -0.050537357 0.032439057 [11] 0.030522697 -0.006024305 -0.078556262 0.033407067 -0.036597174 [16] -0.008729117 -0.049407597 -0.044614175 -0.011110902 -0.077075468 [21] 0.032607364 0.016021868 0.005567218 0.001537240 -0.048756006 [26] 0.002613478 -0.008875975 -0.056785986 -0.001588222 -0.055340980 [31] -0.032941153 -0.028902060 -0.012824150 -0.005957981 -0.004625435 [36] 0.002785216 -0.040881249 -0.015245909 0.001677764 -0.024615587 [41] -0.009982503 -0.047137731 -0.049529024 -0.019092512 -0.004475100 [46] -0.043487442 0.010260211 -0.016140665 > 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/4v4d71352710563.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/57q651352710563.tab") > > try(system("convert tmp/1c8f31352710563.ps tmp/1c8f31352710563.png",intern=TRUE)) character(0) > try(system("convert tmp/2cxhb1352710563.ps tmp/2cxhb1352710563.png",intern=TRUE)) character(0) > try(system("convert tmp/3is4m1352710563.ps tmp/3is4m1352710563.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.516 0.536 3.030