R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(7.14,7.11,7.21,7.25,7.25,7.45,7.45,7.49,7.47,7.49,7.47,7.51,7.52,7.5,7.54,7.54,7.57,7.53,7.54,7.63,7.61,7.64,7.68,7.7,7.72,7.71,7.77,7.83,7.85,7.89,8.01,8.18,8.25,8.31,8.34,8.38,8.36,8.34,8.34,8.3,8.35,8.36,8.34,8.39,8.23,8.14,8.04,8.05,7.99,8.17,8.22,8.12,8.11,8.12,8.11,8.03,8.03,7.96,7.96,7.87,7.9,7.87,7.94,7.82,7.83,7.86,7.81,7.76,7.75,7.75,7.74,7.72) > 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.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/1pgn11363711347.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/2s6tr1363711347.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/32utf1363711347.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.950431598 0.893813753 0.837923629 0.780557901 [6] 0.718136059 0.675143971 0.631143940 0.584597485 0.533301793 [11] 0.479584921 0.422877029 0.367056106 0.308528314 0.249804880 [16] 0.198783428 0.148587434 0.100212706 0.048283269 -0.002317167 [21] -0.051575275 -0.101276440 -0.147789064 -0.194486395 -0.241666252 [26] -0.286716429 -0.332369764 -0.372828755 -0.408524157 -0.440907138 [31] -0.471235790 -0.491043503 -0.496959078 -0.492478787 -0.479348204 [36] -0.461886666 -0.439946030 -0.416442990 -0.390615823 -0.367618720 [41] -0.343036316 -0.310765257 -0.276085662 -0.242897049 -0.203827721 [46] -0.180483929 -0.165803586 -0.159454699 -0.153499146 > (mypacf <- c(rpacf$acf)) [1] 0.9504315981 -0.0983294530 -0.0173536422 -0.0472215955 -0.0828787826 [6] 0.1749793366 -0.0698104402 -0.0455835997 -0.0802805966 -0.0765479358 [11] -0.0179579650 -0.0352294789 -0.0722525710 -0.0559280592 0.0288125026 [16] -0.0468301048 -0.0112390728 -0.1004679897 -0.0389699938 -0.0057953908 [21] -0.0643199466 -0.0008381268 -0.0944345510 -0.0628120342 -0.0276093064 [26] -0.0817307127 0.0080891660 -0.0376711355 -0.0385257710 -0.0359714817 [31] 0.0399405346 0.0945922486 0.0670896349 0.0533149983 -0.0035828291 [36] 0.0531107836 0.0201816634 0.0385965688 -0.0429463575 -0.0183972286 [41] 0.0856454304 -0.0039771874 -0.0041718900 0.0237314708 -0.2101480706 [46] -0.0417968197 -0.1118879119 -0.0363442505 > 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/49p3z1363711347.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/5m76b1363711347.tab") > > try(system("convert tmp/1pgn11363711347.ps tmp/1pgn11363711347.png",intern=TRUE)) character(0) > try(system("convert tmp/2s6tr1363711347.ps tmp/2s6tr1363711347.png",intern=TRUE)) character(0) > try(system("convert tmp/32utf1363711347.ps tmp/32utf1363711347.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.806 0.247 2.045