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(679,687,638,628,604,713,712,693,697,555,486,470,465,426,384,379,381,380,351,346,339,336,333,324,324,321,304,343,407,389,361,353,361,387,692,704,742,721,843,847,945,946,946,945,1082,1075,820,832,851,1090,1203,1239,1535,1527,1480,1452,1383,1381,1429,1376,1602,1597,2003,1958,1997,1986,2129,2115,2297,2250,2309,2648,2627,2711,2732,2825,2932,2910,2969,2999,2965,2846,2847,2751) > 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/1xke11384522697.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/22kjl1384522697.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/3o0yb1384522697.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.972745492 0.942704929 0.908907029 0.871735002 [6] 0.832060243 0.792859418 0.754425274 0.715491779 0.676853106 [11] 0.636746761 0.593931756 0.550002487 0.506299209 0.467910000 [16] 0.429654609 0.389925521 0.353306541 0.315978320 0.279600929 [21] 0.242131118 0.206180413 0.169278685 0.140251399 0.110984617 [26] 0.084940166 0.059893912 0.033517478 0.006472876 -0.023996600 [31] -0.054755900 -0.086859471 -0.118509376 -0.143272733 -0.167674913 [36] -0.187487404 -0.202336850 -0.216681392 -0.233160128 -0.254664384 [41] -0.276351867 -0.293563664 -0.310245865 -0.326789068 -0.342692632 [46] -0.356015291 -0.369214887 -0.381489267 -0.393850216 > (mypacf <- c(rpacf$acf)) [1] 9.727455e-01 -6.563346e-02 -8.306699e-02 -7.468515e-02 -5.768436e-02 [6] -1.979707e-03 -6.627737e-06 -2.982174e-02 -1.867442e-02 -5.361608e-02 [11] -7.512163e-02 -4.094783e-02 -1.443183e-02 8.197085e-02 -2.598089e-02 [16] -7.043575e-02 1.816301e-02 -5.002267e-02 -7.664174e-03 -4.470633e-02 [21] -2.079827e-03 -4.468314e-02 1.158545e-01 -5.510228e-02 1.831890e-02 [26] -2.383558e-02 -6.109948e-02 -4.317428e-02 -9.868811e-02 -1.819718e-02 [31] -4.672811e-02 -2.390831e-02 9.304852e-02 -4.197198e-02 3.904015e-02 [36] 7.096124e-02 -4.312277e-02 -8.437743e-02 -1.152402e-01 -5.438438e-02 [41] 9.340900e-02 -3.573819e-02 -3.572390e-02 -4.995324e-02 1.134293e-02 [46] -1.667980e-02 -1.432257e-02 -2.743243e-02 > 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/41k791384522697.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/5vv8s1384522697.tab") > > try(system("convert tmp/1xke11384522697.ps tmp/1xke11384522697.png",intern=TRUE)) character(0) > try(system("convert tmp/22kjl1384522697.ps tmp/22kjl1384522697.png",intern=TRUE)) character(0) > try(system("convert tmp/3o0yb1384522697.ps tmp/3o0yb1384522697.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.835 0.385 2.197