R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(78.7,75.7,77.1,86.1,86.8,86.3,91.5,90.7,78.2,73,73.7,77.3,67.5,72.7,76.6,82.4,82.3,86.3,93,88.8,96.9,103.9,115.7,112.8,114.7,118,129.3,137,156,166.2,167.8,144.3,126,90.4,67.5,52.4,54.6,52.9,59.1,63.3,73.8,87.6,81.8,90.7,86.3,93.6,98,94.3,97.6,94.2,100.2,106.7,95.7,94.6,94.7,96.2,96.3,103.3,106.8,113.7,117.4,123.6,137.6,147.4,137.2,133.8,136.7,127.3,128.7,127,133.7,132) > 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/196xj1334051206.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/2q9z51334051206.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/3muw81334051206.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.00000000 0.92814769 0.79782929 0.63047164 0.45594939 0.28738300 [7] 0.14296342 0.03901215 -0.04323081 -0.12035323 -0.17402914 -0.20565457 [13] -0.22920407 -0.25057673 -0.25587559 -0.25140896 -0.24364594 -0.22941809 [19] -0.20915790 -0.18415145 -0.16969439 -0.15818112 -0.15041467 -0.14484957 [25] -0.15801169 -0.16521829 -0.18237383 -0.18340532 -0.16342747 -0.11539555 [31] -0.04059628 0.03889343 0.12302046 0.20119067 0.25166663 0.27970179 [37] 0.29194252 0.30140763 0.29965039 0.28838909 0.26253969 0.22246415 [43] 0.16917991 0.11111063 0.06327456 0.01913076 -0.01920160 -0.04814488 [49] -0.07495752 -0.10495939 -0.13348909 -0.14779912 -0.15165417 -0.15673651 [55] -0.16279148 -0.15961443 -0.15598922 -0.15660800 -0.15381327 -0.14574923 [61] -0.13673315 > (mypacf <- c(rpacf$acf)) [1] 0.928147690 -0.459275224 -0.218182208 -0.015730732 -0.049065516 [6] 0.032791037 0.108196308 -0.156819256 -0.204563862 0.143746306 [11] 0.036854026 -0.146956538 -0.058093088 0.084088840 -0.095428454 [16] -0.019666569 0.088336506 -0.111606174 -0.055270554 -0.019584823 [21] 0.000277716 -0.105779697 0.032194007 -0.184321937 0.072449634 [26] -0.164241775 0.187302048 0.126268648 0.017645341 0.040013762 [31] -0.041413449 0.093907411 -0.002783132 -0.066044777 0.008170038 [36] 0.078208346 0.081748984 0.008489154 -0.018613539 -0.170943397 [41] 0.003779113 0.059980356 0.111568742 -0.027027077 -0.028123301 [46] -0.038260576 0.057881087 -0.106812659 0.006963677 -0.031724401 [51] 0.108296551 -0.066783082 -0.107071855 0.010903084 0.026809161 [56] 0.009244009 0.013816405 0.003953637 0.005957557 -0.036771161 > 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/4e0871334051206.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/5dqq91334051206.tab") > > try(system("convert tmp/196xj1334051206.ps tmp/196xj1334051206.png",intern=TRUE)) character(0) > try(system("convert tmp/2q9z51334051206.ps tmp/2q9z51334051206.png",intern=TRUE)) character(0) > try(system("convert tmp/3muw81334051206.ps tmp/3muw81334051206.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.007 0.219 1.232