R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(123,146,156,127,128,147,128,139,130,118,147,98,141,138,130,145,123,116,90,110,102,109,111,93,120,81,84,87,110,90,108,101,87,118,82,86,103,93,83,91,69,95,96,105,121,101,111,130,134,161,186,244,145,170,164,124,154,126,173,140,142,129,171,107,98,185,142,135,126,126,134,119,134,133,129,96,150,113,99,164,127,148,166,115,199,141,149,131,171,178,181,129,112,186,153,116,190,169,165,160,202,155,257,171,168,202,189,132) > 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/1rear1413362932.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/2eiz21413362932.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/37t231413362932.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.532960722 0.008401355 0.140538447 -0.071841396 [6] 0.004174359 -0.016480851 0.001625433 -0.046608110 0.203207067 [11] -0.229155122 -0.009720408 0.211175171 -0.331285184 0.289690727 [16] -0.128030607 0.014027331 0.013476979 0.069323039 -0.124978251 [21] 0.044184248 0.059994591 -0.142403760 0.200414302 -0.097255896 [26] -0.108099202 0.165731127 -0.209716402 0.134983223 -0.007220303 [31] -0.064494849 0.057290187 0.040287620 -0.112911616 0.028178194 [36] 0.093653192 -0.137896166 0.123436789 -0.003106004 -0.069596361 [41] 0.097408617 -0.051584373 -0.074980847 0.089386663 -0.008134059 [46] -0.103040690 0.183418670 -0.127456510 -0.008957668 > (mypacf <- c(rpacf$acf)) [1] -0.532960722 -0.385005478 -0.095851431 -0.016835069 0.009021799 [6] -0.044460810 -0.060220905 -0.131556332 0.191976808 0.013370310 [11] -0.179379535 0.022198187 -0.279124077 0.046252358 0.005375886 [16] 0.039155954 -0.033802044 0.063224773 -0.022040162 -0.008208412 [21] -0.035157759 -0.061082497 0.049771383 0.059581363 -0.078293913 [26] -0.096525443 -0.252558929 -0.092593415 0.057974117 -0.060288518 [31] 0.030759073 -0.063622912 -0.105844569 -0.035859535 0.002937891 [36] -0.028328736 -0.016503374 -0.042799346 0.032249828 -0.007613684 [41] 0.052103582 -0.086995827 -0.061984634 -0.018513672 -0.101573775 [46] 0.040410163 -0.054531438 0.007355351 > 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/4k99h1413362932.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/5f9il1413362932.tab") > > try(system("convert tmp/1rear1413362932.ps tmp/1rear1413362932.png",intern=TRUE)) character(0) > try(system("convert tmp/2eiz21413362932.ps tmp/2eiz21413362932.png",intern=TRUE)) character(0) > try(system("convert tmp/37t231413362932.ps tmp/37t231413362932.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.159 0.242 1.404