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(28886,28549,33348,29017,30924,30435,29431,30290,31286,30622,31742,30391,30740,32086,33947,31312,33239,32362,32170,32665,31412,34891,33919,30706,32846,31368,33130,31665,33139,32201,32230,30287,31918,33853,32232,31484,31902,30260,32823,32018,32100,31952,33274,29491,32751,33643,31226,30976,28880,29325,34923,32642,31487,33832,32724,29545,32338,32743,32231,32536) > 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.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/12nq81476815580.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/25ie31476815580.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/30lzf1476815580.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.47490507 -0.10463397 0.15766693 -0.11444825 -0.06305653 [7] 0.22714508 -0.18117383 0.13131692 0.03190723 -0.21014730 -0.05493097 [13] 0.44831298 -0.37458504 0.19523554 -0.14238314 -0.02265607 0.10885095 [19] -0.03454063 -0.04495589 0.15787302 -0.12675951 -0.03597210 -0.03908289 [25] 0.16195416 -0.09851506 0.14208072 -0.27191982 0.17826923 -0.01467927 [31] -0.09281819 0.09045955 0.07111948 -0.13149996 0.05707726 -0.11527489 [37] 0.08693973 0.07134027 -0.04163801 -0.12267086 0.22233289 -0.20822361 [43] 0.05051599 0.11191597 -0.09674317 0.01571468 0.02850704 -0.13893260 [49] 0.14085129 > (mypacf <- c(rpacf$acf)) [1] -0.474905071 -0.426318457 -0.182527798 -0.227897170 -0.332504413 [6] -0.071269143 -0.173876885 0.057517848 0.184450756 0.017177889 [11] -0.308732673 0.262015383 0.069542248 0.305267227 -0.098364285 [16] -0.043467779 0.053283644 -0.018205658 0.044238050 -0.069352421 [21] -0.032929332 0.046011736 -0.073068990 -0.082374952 -0.058402518 [26] 0.047029151 -0.090723501 -0.046716614 -0.067854662 -0.095874952 [31] -0.085352680 0.009550296 -0.017915643 -0.007092880 -0.034274044 [36] -0.111877670 0.038164186 -0.104200911 -0.003608732 0.067732824 [41] -0.009305048 0.039774751 0.106977129 0.064548309 0.018659484 [46] -0.050741419 0.008576866 -0.019457032 > 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/41uv91476815580.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/53sg51476815580.tab") > > try(system("convert tmp/12nq81476815580.ps tmp/12nq81476815580.png",intern=TRUE)) character(0) > try(system("convert tmp/25ie31476815580.ps tmp/25ie31476815580.png",intern=TRUE)) character(0) > try(system("convert tmp/30lzf1476815580.ps tmp/30lzf1476815580.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.145 0.095 1.272