R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 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(173019,173690,172439,171914,171968,169500,173898,172308,171568,164939,161275,160770,162466,160185,154836,154103,150495,142707,149962,149967,144572,143819,141070,144119,145330,143279,139063,139202,133632,134476,141859,140693,138047,138346,140167,146796,152228,155410,159032,160312,157687,160141,167421,167628,164403,163405,163229,171154,173323,172381,168983,165380,161641,161933,172018,168455,164332,161193,157645,161694,163411,161834,159511,156359,154223,151497,160607,159672,155601,154668,153960,157307,165218,165616,162212,159787,157454,156485,165887,166836,163541,163973,164805,167521,174347,173374,172198,171055,168385,167281,177670,177280,174846,174476,174595,178392,185345,183293,181081,177795,173552,170734,179293,178659,175894,174815,173506,175376) > 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/1bnoo1445439478.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/24o3v1445439478.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/3zxam1445439478.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.93902039 0.86603588 0.81758812 0.78398167 0.76674829 [7] 0.73230946 0.64894400 0.54701832 0.45927695 0.39558250 0.36369626 [13] 0.32121305 0.21198239 0.10543880 0.03406132 -0.01552037 -0.03814652 [19] -0.06647780 -0.12769265 -0.19791015 -0.24245145 -0.25512263 -0.23307421 [25] -0.21861354 -0.25224767 -0.28313295 -0.28023495 -0.25183709 -0.19705425 [31] -0.14965593 -0.12924526 -0.12082994 -0.09507462 -0.04955822 0.01161194 [37] 0.06055834 0.06350173 0.06033477 0.07590410 0.10252129 0.14119331 [43] 0.16412926 0.16153383 0.13893743 0.12938708 0.13234604 0.14528824 [49] 0.14721645 > (mypacf <- c(rpacf$acf)) [1] 0.939020394 -0.132978108 0.181582382 0.056753040 0.145474332 [6] -0.158672385 -0.367167253 -0.209469921 -0.083086760 0.011490538 [11] 0.197693229 -0.012692297 -0.452556778 0.095023244 0.166219888 [16] 0.011719679 0.029865902 0.001804630 0.020865555 -0.037313951 [21] 0.057996855 0.006803497 0.063351065 0.027131426 -0.082385395 [26] -0.017657841 0.079812950 0.096900388 0.050079337 -0.002398888 [31] 0.117278271 0.014452658 -0.014590791 -0.121124919 -0.134146317 [36] 0.013976559 -0.059946002 -0.030306794 -0.043485198 -0.017125881 [41] 0.043924112 -0.004919830 0.106316315 -0.064485081 0.072463290 [46] -0.050015560 -0.007413364 -0.017543901 > 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/4h1261445439478.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/580ro1445439478.tab") > > try(system("convert tmp/1bnoo1445439478.ps tmp/1bnoo1445439478.png",intern=TRUE)) character(0) > try(system("convert tmp/24o3v1445439478.ps tmp/24o3v1445439478.png",intern=TRUE)) character(0) > try(system("convert tmp/3zxam1445439478.ps tmp/3zxam1445439478.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.082 0.222 1.313