R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 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(46.83,45.93,45.93,45.93,45.9,45.91,45.85,45.58,45.56,45.5,45.5,45.5,45.51,45.49,45.4,45.38,45.38,45.38,45.49,45.41,44.99,44.98,44.93,44.93,44.91,44.86,44.76,44.89,44.89,45,45.01,45.11,45.05,44.67,44.48,44.48,44.48,44.58,44.79,44.79,44.41,44.41,44.44,44.43,44.36,44.39,44.39,44.41,44.32,44.43,44.82,44.97,44.91,44.79,44.76,44.8,44.65,44.49,44.56,44.4,44.45,44.46,44.39,44.5,44.44,44.41,44.4,44.42,44.49,44.46,44.49,44.5) > 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/wessaorg/rcomp/tmp/1svpi1352736754.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/230vu1352736754.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/34t5l1352736754.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.861363596 0.795444422 0.736399162 0.681162209 [6] 0.632489490 0.582614059 0.527218164 0.493551248 0.454510944 [11] 0.424298106 0.402494492 0.384087185 0.356260243 0.310983694 [16] 0.264542473 0.227108205 0.196632067 0.178256968 0.152792259 [21] 0.112233731 0.099759973 0.080858548 0.059832015 0.032767102 [26] 0.005440652 -0.022171067 -0.042237232 -0.076571720 -0.103200017 [31] -0.137463238 -0.156946593 -0.185073992 -0.219772270 -0.236563643 [36] -0.241808105 -0.245180114 -0.246364903 -0.251057679 -0.269460172 [41] -0.300228291 -0.294536794 -0.288442382 -0.285791401 -0.281173714 [46] -0.266515474 -0.259734504 -0.250905594 -0.247152053 > (mypacf <- c(rpacf$acf)) [1] 0.8613635956 0.2073110132 0.0595426020 0.0145903809 0.0134634587 [6] -0.0130851366 -0.0458221992 0.0451230702 -0.0048638856 0.0187140782 [11] 0.0357433336 0.0296634500 -0.0292703649 -0.0990601023 -0.0701800141 [16] -0.0204153498 0.0070452703 0.0460228312 -0.0048176112 -0.0788172930 [21] 0.0459315447 -0.0069074523 -0.0312693598 -0.0587154370 -0.0344331203 [26] -0.0257095257 0.0069040847 -0.0493803832 -0.0298809565 -0.0725215839 [31] -0.0017331359 -0.0404844745 -0.0699951905 0.0072465906 0.0354249513 [36] 0.0276455899 0.0126344577 0.0005491191 -0.0847356508 -0.1366071751 [41] 0.0819945900 0.0605203372 0.0106548076 0.0064947782 0.0540759401 [46] -0.0139516743 -0.0286484474 -0.0460145947 > 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/4t9xp1352736754.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/5bqa71352736754.tab") > > try(system("convert tmp/1svpi1352736754.ps tmp/1svpi1352736754.png",intern=TRUE)) character(0) > try(system("convert tmp/230vu1352736754.ps tmp/230vu1352736754.png",intern=TRUE)) character(0) > try(system("convert tmp/34t5l1352736754.ps tmp/34t5l1352736754.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.857 0.740 3.581