R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 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(38,35,33,35,33,32,33,38,45,42,40,44,50,37,37,35,33,40,38,39,52,48,49,50,48,45,42,39,38,44,47,45,51,51,47,49,44,40,40,38,36,45,39,43,50,49,47,49,58,43,39,44,45,57,54,52,61,59,60,58,52,49,60,51,52,56,56,57,58,100,70,70) > 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/fisher/rcomp/tmp/1ck4x1363455064.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/fisher/rcomp/tmp/26ly21363455064.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/fisher/rcomp/tmp/3vz081363455064.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.692227860 0.576048169 0.414493219 0.320091235 [6] 0.246243095 0.192584494 0.199361884 0.205533218 0.283494431 [11] 0.299920023 0.342476513 0.364109817 0.324680930 0.217942946 [16] 0.149524123 0.062369623 -0.030447551 -0.047249247 -0.120138778 [21] -0.081925406 0.076417907 0.076187885 0.112453821 0.108804034 [26] 0.065283852 0.002794636 -0.057879771 -0.095101005 -0.157330003 [31] -0.143410895 -0.127089390 -0.076904323 0.002156520 0.043984400 [36] 0.059589047 0.111929724 0.061284613 -0.011591488 -0.040717432 [41] -0.101751107 -0.150925568 -0.165789901 -0.178584243 -0.123805913 [46] -0.064447751 -0.056344090 -0.061538395 -0.076531997 > (mypacf <- c(rpacf$acf)) [1] 0.692227860 0.185992568 -0.077260461 0.003681616 0.019174499 [6] 0.004542092 0.097831000 0.063664557 0.171061482 0.039675491 [11] 0.078451282 0.085132104 -0.044538589 -0.159334945 -0.019671078 [16] -0.071430620 -0.128389730 0.011409748 -0.143161061 0.024275375 [21] 0.314039556 -0.145094003 -0.026363543 0.050389583 -0.126025304 [26] -0.013156655 0.005968736 -0.007702891 -0.009152778 0.017569724 [31] 0.059024146 0.067797150 -0.014103140 -0.021074277 0.042926391 [36] 0.055257458 -0.090298193 -0.070282732 -0.001448552 0.056494733 [41] -0.062177625 -0.127725507 -0.030861945 0.046703008 -0.030858790 [46] -0.107050620 -0.026631713 -0.057929551 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4qakm1363455064.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/fisher/rcomp/tmp/5nm6f1363455064.tab") > > try(system("convert tmp/1ck4x1363455064.ps tmp/1ck4x1363455064.png",intern=TRUE)) character(0) > try(system("convert tmp/26ly21363455064.ps tmp/26ly21363455064.png",intern=TRUE)) character(0) > try(system("convert tmp/3vz081363455064.ps tmp/3vz081363455064.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.965 0.263 2.204