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(219.20,232.50,235.60,171.00,165.90,187.60,218.20,249.80,256.50,224.90,200.00,182.50,230.30,252.80,270.60,196.90,184.70,202.50,258.20,283.10,268.50,283.80,231.10,212.10,238.50,262.80,245.50,198.20,167.20,184.20,254.90,246.40,264.50,242.40,186.70,254.70,230.10,253.60,228.00,183.80,150.00,178.50,228.40,228.70,236.70,218.20,173.50,189.10,194.60,213.70,216.30,173.90,156.90,182.90,216.40,234.00,257.30,225.70,201.70,189.20) > 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/1ew7x1337779737.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/2mkp01337779737.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/3txj41337779737.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.10888474 -0.24537093 -0.48871069 -0.34179491 0.25305917 [7] 0.40913614 0.25372906 -0.26555918 -0.40840236 -0.30531926 0.23063874 [13] 0.61664837 0.14842873 -0.14631728 -0.45969611 -0.20218029 0.18237459 [19] 0.29607434 0.16703302 -0.21346026 -0.25117731 -0.24572874 0.28284563 [25] 0.35218592 0.14520396 -0.17927458 -0.34200689 -0.07208824 0.11510119 [31] 0.20817583 0.12344354 -0.19582236 -0.17901427 -0.11612654 0.15812453 [37] 0.23411460 0.12607367 -0.11127058 -0.20071713 -0.06601097 0.01963384 [43] 0.14111308 0.08708165 -0.05658676 -0.11005056 -0.05530915 0.02709552 [49] 0.11688752 > (mypacf <- c(rpacf$acf)) [1] 0.108884737 -0.260313059 -0.463202049 -0.458161931 -0.027796239 [6] 0.038857532 0.048276883 -0.235241818 -0.192143551 -0.375655795 [11] -0.173344809 0.232395136 -0.064346702 -0.004053133 0.007478874 [16] 0.167655011 0.062332839 -0.101111090 -0.138680132 -0.123177957 [21] 0.065943785 -0.126528431 0.051205154 -0.032314851 0.095996975 [26] -0.067635214 0.028811718 0.027763965 -0.019701667 -0.131287206 [31] 0.113661527 -0.070147971 0.017533068 -0.015751208 -0.143728131 [36] -0.132467733 -0.040085206 0.066827234 0.017311571 -0.028196906 [41] -0.033224685 -0.018422081 0.080672939 0.044657162 -0.018587047 [46] 0.079054557 0.082282701 0.019073130 > 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/4zu6s1337779737.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/5nx9e1337779737.tab") > > try(system("convert tmp/1ew7x1337779737.ps tmp/1ew7x1337779737.png",intern=TRUE)) character(0) > try(system("convert tmp/2mkp01337779737.ps tmp/2mkp01337779737.png",intern=TRUE)) character(0) > try(system("convert tmp/3txj41337779737.ps tmp/3txj41337779737.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.016 0.242 1.256