R version 3.1.0 (2014-04-10) -- "Spring Dance" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(0.978,0.973,0.96,0.978,0.985,1.035,1.015,1.05,1.022,1.042,1.058,1.056,1.098,1.097,1.139,1.182,1.189,1.191,1.168,1.168,1.177,1.184,1.2,1.251,1.288,1.313,1.363,1.377,1.342,1.334,1.348,1.327,1.349,1.361,1.393,1.38,1.421,1.432,1.457,1.453,1.428,1.383,1.408,1.458,1.474,1.491,1.476,1.446,1.451,1.472,1.449,1.415,1.39,1.394,1.418,1.426,1.437,1.406,1.387,1.404) > 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.291 () > #Author: root > #To cite this work: Wessa P., (2012), (Partial) Autocorrelation Function (v1.0.11) 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) > 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/1rmoz1399754065.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/2535j1399754065.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/3kfvq1399754065.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.144879049 0.059681489 -0.197642232 -0.145275044 [6] -0.042287880 0.048109230 0.048601113 -0.167896011 0.056826535 [11] 0.310976013 0.318837520 0.179673713 -0.042687501 -0.246827586 [16] -0.230795220 -0.036409707 0.038987918 0.013500845 0.093564530 [21] 0.089883602 -0.022508133 0.127871634 0.029256046 -0.128421593 [26] -0.173482532 -0.197768711 -0.026662888 -0.062807603 0.145960951 [31] -0.004617801 0.013482109 -0.096557974 0.077759467 -0.073103871 [36] -0.106445225 -0.143039261 -0.095610782 0.011327637 0.097689931 [41] 0.043214742 -0.060938809 -0.060817461 -0.091910301 0.037003296 [46] -0.015281634 -0.042501052 -0.031710125 -0.042521932 > (mypacf <- c(rpacf$acf)) [1] 0.144879049 0.039521095 -0.216549376 -0.095384824 0.018579950 [6] 0.030378569 -0.008517200 -0.215789014 0.129433622 0.392730929 [11] 0.210335813 0.034125658 -0.006850833 -0.078971148 -0.079696380 [16] -0.056938551 -0.064910442 -0.012022540 0.124913107 0.028303582 [21] -0.263049554 -0.037079421 0.048494600 -0.066906404 -0.047900222 [26] -0.116699470 0.118574016 -0.053553375 -0.121977687 -0.156805381 [31] 0.070190612 -0.061739806 0.126112324 -0.061343235 -0.088991761 [36] -0.015029201 0.087204074 0.021409397 0.002792650 -0.040569415 [41] -0.002057933 0.001157474 -0.153350923 0.012183274 0.061244226 [46] 0.027971320 0.072244375 -0.035014043 > 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/41dbp1399754065.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/51wap1399754065.tab") > > try(system("convert tmp/1rmoz1399754065.ps tmp/1rmoz1399754065.png",intern=TRUE)) character(0) > try(system("convert tmp/2535j1399754065.ps tmp/2535j1399754065.png",intern=TRUE)) character(0) > try(system("convert tmp/3kfvq1399754065.ps tmp/3kfvq1399754065.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.542 0.305 1.867