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(95.77,97.63,100.87,100.39,98.62,97.42,95.62,97.22,97.56,97.06,97.68,98.18,98.54,98.24,98.1,96.32,96.15,96.67,94.7,93.94,96.69,96.54,95.94,95.6,99.15,100.33,99.86,96.09,94.42,93.85,93.73,94.63,95.54,95.48,95.84,96.29,97.63,98.8,99.84,100.73,100.44,100.54,100.25,100.29,100.7,100.62,100.43,99.73,99.17,98.9,98.94,98.91,99.5,99.52,99.1,99.12,99,98.66,98.3,98.18,97.95,97.84,98.61,99.54,99.64,99.69,99.77,99.85,99.87,100.23,100.46,100.36) > 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/1bx751476874007.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/2qw9g1476874007.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/37ui41476874007.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.283262548 -0.191855222 -0.230753525 -0.082653742 [6] -0.054247143 -0.054178866 -0.113018815 -0.058180907 -0.018003431 [11] -0.021201524 -0.050892893 0.160799854 0.113976103 0.035433936 [16] -0.005713079 -0.177548157 -0.074603138 0.036844272 -0.015002676 [21] -0.171012098 -0.036536079 0.150792213 0.156071742 0.079921669 [26] -0.141063300 -0.145804623 -0.040509543 -0.004747975 0.050451113 [31] 0.053463154 0.035595494 0.009322207 -0.038433839 -0.018704974 [36] -0.008400133 0.017407894 0.034671259 0.045686469 0.038555990 [41] -0.033620182 -0.004591734 0.064650285 0.058902675 -0.001679592 [46] -0.003631147 -0.043048237 -0.069256549 -0.034431526 > (mypacf <- c(rpacf$acf)) [1] 0.283262548 -0.295829569 -0.091190898 -0.034461530 -0.113688159 [6] -0.063138910 -0.150926857 -0.048231647 -0.090931008 -0.097769161 [11] -0.108893843 0.156940539 -0.083023392 0.033776235 0.019781599 [16] -0.236274618 0.085435876 -0.067180529 -0.087601509 -0.192294585 [21] 0.026263475 0.043051363 0.006618773 0.016942254 -0.226409754 [26] -0.025259144 -0.195616739 -0.005240833 -0.017127891 -0.076656429 [31] 0.015861036 -0.057897537 -0.063023381 -0.101517562 -0.065265951 [36] -0.234453286 0.049297227 -0.005335451 -0.004948121 -0.028033783 [41] -0.109882832 0.106988471 -0.079473212 -0.002890532 -0.040513406 [46] -0.089787401 -0.050007397 0.049335413 > 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/4ms1j1476874007.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/5trxl1476874007.tab") > > try(system("convert tmp/1bx751476874007.ps tmp/1bx751476874007.png",intern=TRUE)) character(0) > try(system("convert tmp/2qw9g1476874007.ps tmp/2qw9g1476874007.png",intern=TRUE)) character(0) > try(system("convert tmp/37ui41476874007.ps tmp/37ui41476874007.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.179 0.088 1.282