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(134.93,134.37,132.98,130.1,128.24,127.52,126.94,127.38,130.95,128.65,127.37,127.04,125.95,124.06,121.55,119.82,119.19,118.77,118.31,119.47,119.79,117.46,115.74,114.97,112.83,111.44,110.6,109.67,107.96,107.56,116.12,114.38,113.96,113.95,114.99,113.64,112.53,110.59,110.1,109.38,110.43,114.67,114.48,114.76,113.27,111.56,109.89,108.04,107.53,106.11,104.11,103,104.74,104.14,101.98,100.91,100.02,98.49,97.38,95.86,93.99,94.09,93.44,93.61,98.31,103.97,104.12,107.63,105.22,104.59,101.54,99.47) > 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.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/1iryw1476871307.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/2at4q1476871307.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/37y9t1476871307.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.940276716 0.875938664 0.815233597 0.761291865 [6] 0.717811689 0.678139331 0.646483650 0.606772728 0.549487906 [11] 0.497766016 0.446133242 0.382504281 0.318590342 0.259351692 [16] 0.208928662 0.167235597 0.134243766 0.109275161 0.090672762 [21] 0.071839351 0.052795269 0.041501273 0.025829579 0.007037530 [26] -0.010747367 -0.024296227 -0.034670662 -0.033894853 -0.021596251 [31] -0.005080421 -0.009168776 -0.017322038 -0.028861222 -0.046655201 [36] -0.074940904 -0.106175787 -0.133270769 -0.155416139 -0.173729943 [41] -0.188046719 -0.201234503 -0.221782327 -0.256316363 -0.290590234 [46] -0.321553003 -0.350737356 -0.377017749 -0.399042720 > (mypacf <- c(rpacf$acf)) [1] 0.940276716 -0.070604600 -0.001344000 0.022778159 0.056474247 [6] 0.003498013 0.050531748 -0.085696361 -0.160160382 0.032097503 [11] -0.038147094 -0.161332792 -0.055756969 -0.017515354 0.002045668 [16] 0.040340578 0.050909373 0.018787730 0.069179233 0.040039724 [21] -0.004349439 0.065414988 -0.045009552 -0.058139994 -0.027447124 [26] -0.014165427 -0.046023647 0.066289292 0.069199321 0.010527410 [31] -0.145285999 0.013905195 -0.032659434 -0.058530906 -0.123144419 [36] -0.092425299 -0.053767965 0.013465546 0.009822928 -0.031860483 [41] -0.005908597 -0.007639078 -0.084447805 0.008299739 -0.002016355 [46] -0.035020193 -0.028928763 -0.025948399 > 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/421411476871307.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/5vsr91476871307.tab") > > try(system("convert tmp/1iryw1476871307.ps tmp/1iryw1476871307.png",intern=TRUE)) character(0) > try(system("convert tmp/2at4q1476871307.ps tmp/2at4q1476871307.png",intern=TRUE)) character(0) > try(system("convert tmp/37y9t1476871307.ps tmp/37y9t1476871307.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.155 0.085 1.260