R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" 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(90.18,90.5,90.63,90.75,90.76,90.67,90.5,90.8,91.22,92.19,92.51,92.67,93.75,94.1,94.96,95.21,95.33,95.43,95.44,95.64,95.8,95.87,95.98,96.07,96.23,96.32,96.55,96.73,96.61,96.64,96.86,97.02,97.22,98.1,98.46,98.6,98.78,99.13,99.48,99.62,99.68,99.95,100.12,100.25,100.47,100.7,100.88,100.95,100.92,101.12,101.19,101.28,101.28,101.3,101.3,101.36,101.45,101.58,101.73,101.84,102.01,102.14,102.16,102.32,102.41,102.4,102.43,102.42,102.3,102.65,102.72,102.86) > 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/1u37x1457972052.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/2bfry1457972052.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/3wb311457972052.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.95946226 0.91873117 0.87637868 0.83385297 0.78866707 [7] 0.74034973 0.68906922 0.63791436 0.58837327 0.54498232 0.50237821 [13] 0.45956212 0.42325498 0.38827578 0.35865603 0.33023011 0.30195854 [19] 0.27339763 0.24337073 0.21316924 0.18260555 0.15112106 0.11909156 [25] 0.08685214 0.05342457 0.01896463 -0.01468874 -0.04724177 -0.08082394 [31] -0.11497324 -0.14816282 -0.18019057 -0.21186757 -0.23784600 -0.26060804 [37] -0.28166667 -0.30168081 -0.31962151 -0.33412735 -0.34416513 -0.35335513 [43] -0.36033116 -0.36561166 -0.37033702 -0.37458327 -0.37690711 -0.37748166 [49] -0.37769516 > (mypacf <- c(rpacf$acf)) [1] 0.959462259 -0.023122368 -0.041645790 -0.024682904 -0.056380357 [6] -0.064822426 -0.064436342 -0.027898152 -0.008744349 0.049684574 [11] -0.014295367 -0.030771338 0.053516028 -0.014868749 0.031999355 [16] -0.014519175 -0.028852264 -0.032176764 -0.048937437 -0.034468213 [21] -0.035070846 -0.028506869 -0.029016113 -0.021247128 -0.034606862 [26] -0.043260353 -0.013839530 -0.018752360 -0.044691723 -0.043487894 [31] -0.029612742 -0.027453787 -0.040609505 0.029270580 0.003269712 [36] -0.013496270 -0.023557488 -0.018520921 0.001150960 0.017275063 [41] -0.024419815 -0.005455376 -0.001840084 -0.022908591 -0.028309387 [46] 0.002288635 0.002317177 -0.007658986 > 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/4r7zm1457972052.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/5p4721457972052.tab") > > try(system("convert tmp/1u37x1457972052.ps tmp/1u37x1457972052.png",intern=TRUE)) character(0) > try(system("convert tmp/2bfry1457972052.ps tmp/2bfry1457972052.png",intern=TRUE)) character(0) > try(system("convert tmp/3wb311457972052.ps tmp/3wb311457972052.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.372 0.262 1.637