R version 3.3.3 (2017-03-06) -- "Another Canoe" Copyright (C) 2017 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(101.03,100.65,100.66,100.54,100.51,100.53,100.53,101.02,101.07,101.37,101.45,101.44,101.45,100.99,101.11,101.31,101.53,101.6,101.61,102.04,102.36,102.74,102.96,103.01,103.02,102.34,102.38,102.54,102.71,102.78,102.78,103.27,103.4,103.74,103.89,103.92,99.68,99.06,99.12,99.37,99.63,99.69,99.76,100.16,100.46,100.83,101.09,101.14,101.25,101.09,101.18,101.14,101.23,101.17,100.84,101.04,101.18,101.1,101.21,101.26,101.85,101.82,101.93,101.95,101.97,102.04,101.37,101.2,101.14,101.27,101.39,101.4) > 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/1bckf1489760122.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/2psmg1489760122.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/3c3ts1489760122.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.160200688 -0.004636519 -0.112415565 -0.084529002 [6] -0.080033329 -0.089900418 -0.082683793 -0.106552069 -0.101847985 [11] -0.033615171 0.134732587 0.098230578 0.061313326 -0.032316482 [16] -0.054308306 -0.078817092 -0.034794162 0.017235867 -0.045659758 [21] -0.077593534 -0.034715251 -0.034177859 0.062973991 -0.038288522 [26] 0.031559235 -0.019939986 -0.054633920 -0.013397288 -0.052179941 [31] 0.108671673 0.037000779 0.011355933 -0.014990791 -0.020322098 [36] 0.041560418 0.033589478 0.006491947 0.007454240 0.006640532 [41] 0.003565688 0.042252466 -0.007615017 0.001019505 -0.010342949 [46] -0.019163189 -0.007905701 -0.033891921 0.007392947 > (mypacf <- c(rpacf$acf)) [1] 0.160200688 -0.031098910 -0.109583262 -0.050793093 -0.063277664 [6] -0.084675254 -0.076039699 -0.111131854 -0.110062695 -0.049439777 [11] 0.098503878 0.010127530 0.001780546 -0.057748906 -0.056110806 [16] -0.077243479 -0.029280455 0.012015703 -0.064474338 -0.071590864 [21] -0.025392056 -0.087059443 0.008431450 -0.129037550 -0.007159382 [26] -0.063781521 -0.088791692 -0.042351347 -0.129145105 0.069414649 [31] -0.039772745 -0.046435426 -0.040826065 -0.082248386 0.018347517 [36] -0.043830574 -0.031810694 -0.009158551 -0.010626319 0.003569048 [41] -0.013805585 -0.046514510 -0.038139657 -0.024417119 -0.014350543 [46] -0.037907064 -0.042552956 -0.041130803 > 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/43rg01489760122.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/5ek4u1489760122.tab") > > try(system("convert tmp/1bckf1489760122.ps tmp/1bckf1489760122.png",intern=TRUE)) character(0) > try(system("convert tmp/2psmg1489760122.ps tmp/2psmg1489760122.png",intern=TRUE)) character(0) > try(system("convert tmp/3c3ts1489760122.ps tmp/3c3ts1489760122.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.659 0.105 1.821