R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 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(21571,21493,21422,21272,22747,22676,21571,20831,20909,20909,20980,21130,21051,21643,21864,21643,22455,21935,20759,20467,20467,20610,20026,20467,20097,20467,21051,21272,21792,21571,20246,19726,19506,19726,19363,19506,19064,19805,20168,20246,21643,21643,19805,19363,19363,19584,18622,18180,17668,17817,18480,17960,19363,19584,18180,17668,17375,17668,16855,16563,15388,15680,15751,15830,17226,17076,15388,14647,14355,14725,13322,12367,10601,10750,10750,10601,11854,11926,10451,10159,9568,10380,8905,8022,6333,6697,6255,6404,7509,7730,6996,6917,6917,7879,6184,5079,3163,4709,4488,4566,6333,6112,5300,5671,5671,6996,5450,4566,3163,5008,4859,4930,6476,6333,5813,5892,6255,7067,5813,4787) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'GNU S' R Code compiled by R2WASP v. 1.2.327 (Mon, 30 Nov 2015 06:58:35 +0000) > #Author: root > #To cite this work: Wessa P., (2015), (Partial) Autocorrelation Function (v1.0.12) 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) > x <- na.omit(x) > 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/1n49c1470855629.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/2kxvm1470855629.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/3r9t91470855629.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.97755816 0.95635629 0.93892592 0.92222104 0.90223850 [7] 0.88172601 0.86473640 0.84965362 0.83175500 0.81611035 0.80182502 [13] 0.78238230 0.75241043 0.72263161 0.69637361 0.66955598 0.64049719 [19] 0.61027041 0.58433315 0.56048047 0.53434096 0.51013770 0.48886633 [25] 0.46251231 0.42952676 0.39771797 0.36905911 0.33964682 0.30798944 [31] 0.27475752 0.24579335 0.21890573 0.19199502 0.16634728 0.14436684 [37] 0.12054230 0.09194310 0.06391030 0.03890999 0.01320679 -0.01533227 [43] -0.04593315 -0.07021522 -0.09214200 -0.11484419 -0.13594947 -0.15320062 [49] -0.17051575 -0.19023590 -0.20833984 -0.22444262 -0.23969354 -0.25842672 [55] -0.27896022 -0.29374098 -0.30594849 -0.31892852 -0.33122503 -0.33999242 [61] -0.34913358 > (mypacf <- c(rpacf$acf)) [1] 0.9775581604 0.0165915881 0.0749226639 0.0121497399 -0.0748118708 [6] -0.0235216944 0.0576242566 0.0342828730 -0.0544188398 0.0494165352 [11] 0.0094153706 -0.1266981499 -0.2469126933 -0.0500602137 0.0167730083 [16] -0.0177876115 -0.0202792576 -0.0580513033 0.0267634872 0.0205736396 [21] -0.0410309883 0.0154108931 0.0489237838 -0.0786750004 -0.1165741940 [26] -0.0176116286 -0.0018988433 -0.0181002048 -0.0150320984 -0.0746097816 [31] -0.0044050475 0.0117358843 0.0090309330 -0.0131639235 0.0570054630 [36] 0.0062340668 -0.0763411366 -0.0309751908 -0.0027422956 -0.0206524601 [41] -0.0247743171 -0.0717804235 0.0366212555 0.0119884793 -0.0140510260 [46] -0.0150532918 0.0320125343 0.0186759741 -0.0154754231 0.0158149926 [51] -0.0167463680 0.0278651002 -0.0264646394 -0.0609836296 0.0167650899 [56] 0.0152841805 0.0004470597 -0.0330183159 0.0103801114 -0.0333231967 > 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/4u91a1470855629.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/5uwo21470855629.tab") > > try(system("convert tmp/1n49c1470855629.ps tmp/1n49c1470855629.png",intern=TRUE)) character(0) > try(system("convert tmp/2kxvm1470855629.ps tmp/2kxvm1470855629.png",intern=TRUE)) character(0) > try(system("convert tmp/3r9t91470855629.ps tmp/3r9t91470855629.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.262 0.105 1.385