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(52.21,52.53,53.06,53.23,53.25,53.27,53.35,53.6,53.98,54.18,54.27,54.32,54.4,54.73,54.96,55.27,55.27,55.26,55.37,55.53,55.55,55.54,55.6,55.56,55.64,56.13,56.69,56.8,56.93,57,57.01,57.21,57.17,57.36,57.29,57.26,57.29,57.68,58.19,58.34,58.46,58.67,58.72,58.74,58.77,58.84,59.13,59.12,59.12,59.33,59.49,59.67,59.7,59.73,59.74,59.62,59.6,59.98,60.05,60.06,60.1,60.18,60.38,60.52,60.78,60.72,60.72,60.86,60.99,61.11,61.17,61.19) > 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/126ac1352718394.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/263xe1352718395.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/3cvnd1352718395.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.315297329 -0.149959238 -0.247214611 -0.168203967 [6] 0.036338169 0.074690745 0.080996417 -0.114094721 -0.292773511 [11] -0.120576880 0.302450292 0.422405982 0.292285681 -0.135126288 [16] -0.162183511 -0.064512068 -0.082246491 0.071414503 -0.009113827 [21] -0.019633539 -0.205168539 -0.165288090 0.172529507 0.321011465 [26] 0.141004168 0.044718802 -0.126366214 -0.174391693 -0.070999440 [31] -0.028920605 0.174872346 0.001027502 -0.138677547 -0.157558992 [36] 0.038347841 0.189413506 0.104379334 0.122630851 0.008442812 [41] -0.171749547 -0.123216809 0.009441063 0.033298954 0.054461387 [46] -0.097834985 -0.148227818 -0.052626023 0.037077948 > (mypacf <- c(rpacf$acf)) [1] 0.3152973294 -0.2768988219 -0.1197002163 -0.0895829025 0.0619059937 [6] -0.0412864770 0.0551483583 -0.1819673905 -0.2013802982 0.0141985040 [11] 0.3044216671 0.1655281869 0.2081810878 -0.1792072342 0.1745393098 [16] 0.0025799258 -0.1085602679 -0.0073940769 -0.0875823572 0.1583019596 [21] -0.1391472179 -0.0648015420 0.0352609582 0.0801414461 -0.0387586498 [26] 0.1258654517 -0.1513223278 -0.0311940769 0.0028593115 -0.0154880089 [31] 0.0919736725 0.0055315519 -0.0040053794 -0.0381270243 0.0590891527 [36] -0.1263045543 -0.0128594799 0.1559313007 0.0087515491 -0.0455700647 [41] 0.0803540934 -0.1249944090 -0.0071146490 -0.0248433220 0.0372650848 [46] -0.1642199684 0.0045630213 -0.0002982283 > 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/4vd121352718395.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/59wjt1352718395.tab") > > try(system("convert tmp/126ac1352718394.ps tmp/126ac1352718394.png",intern=TRUE)) character(0) > try(system("convert tmp/263xe1352718395.ps tmp/263xe1352718395.png",intern=TRUE)) character(0) > try(system("convert tmp/3cvnd1352718395.ps tmp/3cvnd1352718395.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.174 0.386 2.532