R version 3.3.2 (2016-10-31) -- "Sincere Pumpkin Patch" 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(102.8,103.3,103.3,104,104.3,104.1,103.9,103.8,103.7,103.6,103.6,103.8,104.9,106.2,106.8,107.3,106.9,107.1,106.6,106.8,107.1,107.5,107.6,107.7,108.4,108.8,108.9,109.2,110.1,110.4,110.7,111,111,111.2,111.5,111.4,111.1,110.6,110.8,110.9,110.8,110.9,110.6,110.3,109.7,109.4,109,109.5,109.8,108.5,108.4,108.4,107.9,106.7,106.9,106.9,106.7,106.7,106.6,107.1) > 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/1n5v31489659797.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/2ip6s1489659797.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/3i0101489659797.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.0000000000 0.3493730828 0.1479541499 0.1574564050 0.1609037063 [6] -0.0230463366 -0.0579749158 0.1539019949 0.1063484888 0.2293219726 [11] 0.0952452628 0.1309299739 0.1372307592 0.0785834640 0.0563494089 [16] -0.0619705012 0.0662923676 0.0209102933 -0.0335890105 -0.0420845839 [21] -0.0396812402 -0.0740808809 -0.1729135830 -0.1387878485 -0.1606460788 [26] -0.1937790509 0.0249879797 0.0185107243 -0.0808369968 -0.1688403790 [31] -0.0852032167 -0.0656232910 -0.1715409852 -0.0540100003 -0.0306996663 [36] 0.0823492608 -0.1210044736 -0.0762025330 -0.0666306806 -0.1100640341 [41] -0.1503655149 -0.1646098147 -0.0384348611 -0.0509670704 0.0534796462 [46] -0.0106379867 0.0007990699 0.0850486874 -0.0244463014 > (mypacf <- c(rpacf$acf)) [1] 0.349373083 0.029492499 0.110566131 0.081462041 -0.133896875 [6] -0.041994512 0.204104650 0.004898084 0.246362374 -0.098114422 [11] 0.042709666 0.065407375 -0.017918988 0.049092943 -0.120871421 [16] 0.045241391 0.004645351 -0.114963967 0.012101120 -0.113348007 [21] -0.101483987 -0.077136573 -0.130685244 -0.044047554 -0.166152991 [26] 0.234255732 0.002940686 -0.117258009 -0.069687500 -0.070497743 [31] 0.159056670 0.005067579 0.088787757 0.071929974 0.054774598 [36] -0.097142580 0.033921610 -0.061301241 -0.020662541 -0.140059583 [41] 0.017783356 -0.082839110 -0.037784699 0.050222903 -0.072645486 [46] -0.045967632 0.044610039 -0.072224862 > 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/4fdf41489659797.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/5cbs41489659797.tab") > > try(system("convert tmp/1n5v31489659797.ps tmp/1n5v31489659797.png",intern=TRUE)) character(0) > try(system("convert tmp/2ip6s1489659797.ps tmp/2ip6s1489659797.png",intern=TRUE)) character(0) > try(system("convert tmp/3i0101489659797.ps tmp/3i0101489659797.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.355 0.082 1.459