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(0.66,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.67,0.69,0.7,0.7,0.7,0.7,0.7,0.7,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.72,0.72,0.72,0.72,0.73,0.73,0.73,0.73,0.73,0.73,0.73,0.73,0.73,0.73,0.73,0.73,0.74,0.75,0.75,0.75,0.75,0.76,0.76,0.76,0.77,0.77,0.78,0.78,0.78,0.78,0.79,0.79,0.79,0.8,0.8,0.8,0.8,0.81,0.8,0.81,0.82,0.82,0.82,0.82) > 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/fisher/rcomp/tmp/1x1gj1363711230.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/fisher/rcomp/tmp/2yj6r1363711230.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/fisher/rcomp/tmp/3tdfr1363711230.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.9522081146 0.9078984964 0.8629459981 0.8160648595 [6] 0.7721302547 0.7330708240 0.6865646987 0.6417193471 0.5962311154 [11] 0.5481713633 0.4988258509 0.4543555127 0.4073136541 0.3665934498 [16] 0.3348735669 0.3012250438 0.2650050002 0.2274991964 0.1942256866 [21] 0.1583806565 0.1315359477 0.1040483589 0.0759178899 0.0520197150 [26] 0.0261928997 -0.0002767956 -0.0280322512 -0.0509125326 -0.0635067324 [31] -0.0773866924 -0.0925524126 -0.1102896532 -0.1251875067 -0.1413711204 [36] -0.1575547341 -0.1750241080 -0.1944221222 -0.2144630165 -0.2351467910 [41] -0.2577592057 -0.2761393264 -0.2964480874 -0.3167568485 -0.3377084896 [46] -0.3496598093 -0.3587717418 -0.3672407943 -0.3769956070 > (mypacf <- c(rpacf$acf)) [1] 0.952208115 0.012842515 -0.028821601 -0.045254702 0.004418702 [6] 0.030007791 -0.099089394 -0.016890996 -0.033242950 -0.050891718 [11] -0.049127596 0.012839492 -0.047698094 0.029850188 0.069038708 [16] -0.035235800 -0.055079887 -0.053559932 0.032904368 -0.054258987 [21] 0.048834843 -0.030270419 -0.032768288 0.011898640 -0.046139952 [26] -0.017084652 -0.061004296 0.038065353 0.098149604 -0.041508466 [31] -0.056983357 -0.047965353 0.023415396 -0.030433572 -0.027055242 [36] -0.051257785 -0.049472159 -0.040910578 -0.037534539 -0.057416048 [41] 0.007912914 -0.019291805 -0.021194034 -0.046582517 0.039561242 [46] 0.019758246 -0.014148840 -0.047555288 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4y76m1363711230.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/fisher/rcomp/tmp/5ad3u1363711230.tab") > > try(system("convert tmp/1x1gj1363711230.ps tmp/1x1gj1363711230.png",intern=TRUE)) character(0) > try(system("convert tmp/2yj6r1363711230.ps tmp/2yj6r1363711230.png",intern=TRUE)) character(0) > try(system("convert tmp/3tdfr1363711230.ps tmp/3tdfr1363711230.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.732 0.271 1.994