R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(1.94,1.82,1.8,1.79,1.79,1.78,1.81,1.84,1.87,1.87,1.87,1.84,1.82,1.83,1.83,1.82,1.83,1.87,1.88,1.9,1.98,2.03,2.14,2.42,2.73,2.84,2.85,2.94,3.06,3.24,3.18,3.01,2.87,2.73,2.63,2.39,2.26,2.11,2.01,1.99,1.96,1.93,1.98,2.07,2.24,2.31,2.23,2.26,2.28,2.3,2.33,2.26,2.24,2.47,2.55,2.89,3.21,3.21,2.92,2.68,2.4,2.28,2.24,2.2,2.18,2.23,2.24,2.25,2.23,2.25,2.23,2.21,2.17,2.17,2.13,2.12,2.13,2.17,2.33,2.5,2.57,2.59,2.58,2.31) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/15ek71386195631.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/2ch3k1386195631.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/3z94e1386195631.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.9487698664 0.8345672166 0.6910783703 0.5395845432 [6] 0.3954312313 0.2625319807 0.1410699119 0.0395993673 -0.0442105153 [11] -0.1152071965 -0.1750152164 -0.2280817868 -0.2742473312 -0.3102104490 [16] -0.3350581538 -0.3475609224 -0.3465807919 -0.3278248950 -0.2865922674 [21] -0.2279919706 -0.1578576997 -0.0829832244 -0.0087915269 0.0571492850 [26] 0.1112029620 0.1445247849 0.1578027635 0.1632327217 0.1673651405 [31] 0.1689809607 0.1660894012 0.1501491996 0.1175162585 0.0745343944 [36] 0.0304171833 -0.0139223883 -0.0551149037 -0.0951616082 -0.1301018673 [41] -0.1574687867 -0.1786619300 -0.1933726083 -0.2006669073 -0.1971387861 [46] -0.1810747602 -0.1597133205 -0.1387102738 -0.1159178783 -0.0955034331 [51] -0.0790260781 -0.0677310326 -0.0624187948 -0.0593824829 -0.0520402237 [56] -0.0402612170 -0.0217276807 -0.0001857365 0.0142694452 0.0180513191 [61] 0.0176318860 > (mypacf <- c(rpacf$acf)) [1] 0.948769866 -0.657049694 0.042215626 -0.042027826 0.011882617 [6] -0.101035985 -0.060912501 0.098995248 -0.123792380 -0.064863239 [11] -0.031271575 -0.083702875 -0.017628486 -0.024938787 -0.013786328 [16] -0.012726895 -0.006406101 0.100219722 0.079622619 -0.037657693 [21] 0.050395340 0.007746879 0.038948166 -0.071605704 0.017562487 [26] -0.114742089 0.018312864 0.139827115 -0.005596210 -0.062223818 [31] -0.021613418 -0.100502734 -0.068590112 0.011608771 0.094686865 [36] -0.083644962 0.028994212 -0.050435444 0.054995355 -0.062369276 [41] -0.035685990 0.033234556 -0.017876730 0.038349045 0.013716578 [46] -0.096171478 -0.010163989 0.054956633 -0.082253743 -0.061476254 [51] -0.063577110 0.029154655 -0.019004463 0.006377526 0.025232008 [56] 0.042686563 -0.013295685 -0.109434179 -0.007359414 0.033115393 > 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/4wuql1386195631.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/5p1oz1386195631.tab") > > try(system("convert tmp/15ek71386195631.ps tmp/15ek71386195631.png",intern=TRUE)) character(0) > try(system("convert tmp/2ch3k1386195631.ps tmp/2ch3k1386195631.png",intern=TRUE)) character(0) > try(system("convert tmp/3z94e1386195631.ps tmp/3z94e1386195631.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.341 0.601 3.906