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(1.44,1.45,1.45,1.47,1.49,1.5,1.5,1.5,1.5,1.5,1.5,1.51,1.52,1.51,1.51,1.51,1.52,1.52,1.52,1.52,1.52,1.53,1.53,1.53,1.53,1.54,1.54,1.55,1.56,1.55,1.56,1.56,1.56,1.56,1.57,1.56,1.57,1.58,1.58,1.58,1.6,1.61,1.61,1.61,1.6,1.59,1.56,1.57,1.55,1.59,1.62,1.63,1.62,1.56,1.56,1.54,1.54,1.52,1.56,1.59,1.61,1.56,1.51,1.48,1.49,1.48,1.47,1.47,1.46,1.45,1.45,1.45) > 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/1gwz81353058724.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/21iif1353058724.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/3lv2a1353058724.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.0000000000 0.2631746809 0.0526332276 -0.3492412895 -0.1529893744 [6] -0.1433529062 -0.0716460781 0.0957609791 0.2154527109 0.4162200593 [11] 0.1431364844 -0.0198244325 -0.2349487137 -0.0673394729 -0.0909959013 [16] 0.0859137844 0.0429151266 0.0810594799 0.0571334734 0.0088780425 [21] 0.0040246873 -0.0628316333 0.0474248646 -0.0192966669 0.0714828125 [26] -0.0767187028 -0.0147166867 -0.0434277047 -0.0195035966 -0.0195719403 [31] -0.0003654492 0.0044860076 -0.0336602443 0.0620390357 -0.0288097367 [36] -0.0240256745 -0.0430318805 -0.0047527380 0.0240237760 0.0288078383 [41] -0.0093384136 -0.1145422203 -0.0522706260 -0.0284139125 0.0050802185 [46] -0.0379858339 0.0479412396 0.0289350336 0.0383693182 > (mypacf <- c(rpacf$acf)) [1] 0.263174681 -0.017865034 -0.385449976 0.044313830 -0.079779495 [6] -0.181415139 0.169588883 0.136712804 0.292621643 0.026855122 [11] -0.005803665 0.028362397 0.104633402 -0.063445712 0.102163007 [16] -0.033653721 -0.125275128 -0.037191811 -0.045684329 0.022486320 [21] 0.016059872 0.045929812 -0.010826715 0.027614399 -0.085951910 [26] 0.014040202 0.049038723 -0.111146820 -0.028689418 -0.005590474 [31] -0.131713960 -0.038001383 0.117290271 -0.037458853 -0.038518895 [36] 0.097193150 -0.034917349 0.090771379 0.057537481 -0.037807424 [41] -0.084645527 -0.061835902 -0.045703473 -0.041299505 -0.081350377 [46] 0.037996278 0.014499797 -0.046891507 > 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/48xws1353058724.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/5gchb1353058724.tab") > > try(system("convert tmp/1gwz81353058724.ps tmp/1gwz81353058724.png",intern=TRUE)) character(0) > try(system("convert tmp/21iif1353058724.ps tmp/21iif1353058724.png",intern=TRUE)) character(0) > try(system("convert tmp/3lv2a1353058724.ps tmp/3lv2a1353058724.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.811 0.312 2.121