R version 3.0.3 (2014-03-06) -- "Warm Puppy" 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,-2,-4,-6,-2,1,7,2,2,13,7,-1,1,0,0,5,3,6,7,-6,-8,-5,-14,-13,-15,-14,-10,-14,-18,-22,-24,-17,-16,-17,-22,-25,-18,-23,-20,-9,-4,0,3,14,13,12,16,7,2,1,7,10,3,2,12,14,11,13,17,14,7,16,5,5,15,9,4,-9,-14,-4,-19,-10,-22) > 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/1f1ee1395071772.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/2irxz1395071772.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/3e7bk1395071772.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.170157448 -0.074035753 0.163716040 -0.066649798 [6] 0.128207417 -0.125586659 0.023017202 0.103031332 -0.171560115 [11] 0.110978817 0.010918909 -0.007594507 -0.094312901 -0.006031815 [16] 0.159490707 -0.149385207 -0.119471943 0.140699416 -0.016220505 [21] -0.061208974 -0.083996250 -0.017458815 0.023258682 -0.170347801 [26] 0.117952002 -0.037990442 -0.092306532 0.018290133 -0.136154901 [31] 0.057069720 -0.111070383 -0.066380587 0.117308439 -0.021174612 [36] -0.008855925 -0.069016076 0.086825270 0.085667261 -0.091748470 [41] 0.077340802 -0.011613310 -0.069319371 0.044542481 -0.044016481 [46] 0.051980430 0.082642398 -0.090520269 0.122160292 > (mypacf <- c(rpacf$acf)) [1] -0.170157448 -0.106060128 0.137206602 -0.022094240 0.144836695 [6] -0.119127515 0.020320999 0.050411963 -0.106061165 0.059375799 [11] 0.019537047 0.043246429 -0.148126960 0.011823806 0.098258211 [16] -0.072744981 -0.139202215 0.062897604 0.035561752 -0.056338864 [21] -0.085698679 -0.077507148 -0.017258496 -0.119774819 0.092141693 [26] -0.077573267 -0.020305173 -0.034055209 -0.157337206 -0.062797979 [31] -0.071587997 -0.008807172 -0.041925011 0.085129841 -0.008269241 [36] -0.098239341 0.017289345 0.080583173 -0.006033052 -0.005967737 [41] -0.006196199 -0.092383927 -0.038533012 -0.065135270 -0.003570315 [46] 0.107566376 -0.015368321 0.021000345 > 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/4x1qo1395071772.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/5snno1395071772.tab") > > try(system("convert tmp/1f1ee1395071772.ps tmp/1f1ee1395071772.png",intern=TRUE)) character(0) > try(system("convert tmp/2irxz1395071772.ps tmp/2irxz1395071772.png",intern=TRUE)) character(0) > try(system("convert tmp/3e7bk1395071772.ps tmp/3e7bk1395071772.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.995 0.626 3.598