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(33.7,34.59,35.1,35.87,37.15,37.61,37.97,38.94,39.18,39.49,39.86,40.02,40.2,40.85,41.45,41.7,41.92,41.97,42.31,42.61,42.82,43.07,43.51,43.57,43.86,44.49,45.99,48.22,49.46,50.39,50.4,50.59,51.32,51.86,52.47,52.73,52.73,53.59,54.11,54.8,55.72,56.06,56.66,57.05,57.31,57.89,58.32,58.72,59.02,59.54,61.49,62.26,63.49,64.36,65.93,66.82,68.85,71.27,72.27,73.4,73.58,74.84,75.74,77.81,78.74,79.06,79.48,81.19,85.11,86.64,88.48,89.2) > 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/16xal1363733029.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/2h3ih1363733029.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/3bq8w1363733029.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.947848662 0.894809938 0.843190319 0.793217271 [6] 0.750660144 0.709574512 0.667192969 0.624148351 0.581320631 [11] 0.541130881 0.501213202 0.461611605 0.420177815 0.379563083 [16] 0.339651443 0.303297952 0.269675174 0.236166993 0.204461567 [21] 0.173346890 0.143563230 0.114280132 0.088174158 0.061550594 [26] 0.034278017 0.007064448 -0.018717508 -0.041701078 -0.064022908 [31] -0.085837150 -0.108020644 -0.130675392 -0.151551705 -0.171299649 [36] -0.190271799 -0.208321537 -0.227723699 -0.246541703 -0.264347096 [41] -0.281142849 -0.296333327 -0.312122303 -0.328421066 -0.343486596 [46] -0.356555700 -0.364940820 -0.370370654 -0.374672085 -0.378713219 [51] -0.382786608 -0.384152064 -0.384629299 -0.383733650 -0.381798108 [56] -0.377829829 -0.373315959 -0.366287181 -0.356054213 -0.343727814 [61] -0.329016549 > (mypacf <- c(rpacf$acf)) [1] 0.9478486615 -0.0355093842 -0.0139337549 -0.0120105147 0.0451349562 [6] -0.0109745156 -0.0354337539 -0.0296517605 -0.0192753594 0.0004616698 [11] -0.0255346814 -0.0241200394 -0.0443312555 -0.0168004980 -0.0221088445 [16] 0.0049221277 -0.0043084945 -0.0251360138 -0.0068234903 -0.0166812184 [21] -0.0102073926 -0.0232116424 0.0060765526 -0.0303764712 -0.0293288975 [26] -0.0259016219 -0.0110290104 -0.0015246308 -0.0229206245 -0.0210972210 [31] -0.0284472305 -0.0265330446 -0.0112077879 -0.0175167999 -0.0221257718 [36] -0.0181814643 -0.0382801722 -0.0207847329 -0.0197142002 -0.0223068842 [41] -0.0161105743 -0.0354292875 -0.0326088392 -0.0185237461 -0.0111057288 [46] 0.0128895252 -0.0013847567 -0.0131131304 -0.0179804958 -0.0191747965 [51] 0.0038947875 -0.0171122451 -0.0117823831 -0.0117302569 0.0036222537 [56] -0.0133584117 0.0047462036 0.0117597084 0.0062976022 0.0138667639 > 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/4twit1363733029.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/5539y1363733029.tab") > > try(system("convert tmp/16xal1363733029.ps tmp/16xal1363733029.png",intern=TRUE)) character(0) > try(system("convert tmp/2h3ih1363733029.ps tmp/2h3ih1363733029.png",intern=TRUE)) character(0) > try(system("convert tmp/3bq8w1363733029.ps tmp/3bq8w1363733029.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.753 0.266 1.995