R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 The R Foundation for Statistical Computing 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(580,610,550,515,555,580,585,545,580,605,625,600,590,605,475,535,560,610,585,560,590,625,620,615,560,665,495,555,545,605,610,610,550,600,660,590,555,650,530,565,580,630,605,595,565,585,685,585,520,670,525,565,575,610,605,575,565,575,720,580,565,675,525,575,560,585,550,560,605,585,685,585,555,660,530,575,580,615,570,550,635,580,690,575,590,685,540,580,615,605,565,555,625,605,685,540,610,680,560,575,590,625,520,590,625,560,715,575) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1f6dy1377083497.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/2st1s1377083497.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/30a8t1377083497.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.183922154 -0.064857640 0.125865940 -0.076290265 [6] -0.002689779 -0.196314101 0.022976634 -0.142256585 0.165891311 [11] -0.057341210 -0.153710816 0.773038295 -0.172085772 -0.050089441 [16] 0.074660620 -0.025923028 -0.032144089 -0.152055749 0.041167152 [21] -0.211509728 0.155892219 -0.078330800 -0.133815753 0.619827922 [26] -0.185052299 -0.031886711 0.057578763 -0.012860391 -0.019101805 [31] -0.118351328 0.029296622 -0.252599718 0.131791707 -0.075760019 [36] -0.092433247 0.479256622 -0.153177592 -0.019485539 0.079032849 [41] 0.018794506 -0.046749805 -0.115330750 0.046679136 -0.245034366 [46] 0.110797028 -0.067210610 -0.049442873 0.370473303 -0.118685519 [51] -0.009995832 0.078505938 0.076696341 -0.036206842 -0.104092739 [56] 0.012551829 -0.210915766 0.095887829 -0.084218180 -0.013665522 [61] 0.257168615 > (mypacf <- c(rpacf$acf)) [1] -0.1839221542 -0.1021401301 0.0982466675 -0.0415080089 -0.0085479073 [6] -0.2316347289 -0.0496882334 -0.1999672959 0.1693899258 -0.0651794184 [11] -0.1314183104 0.7297243603 0.0298269662 0.0165022449 -0.0334457841 [16] -0.0071165249 -0.0128432392 0.0706806264 0.0125095146 -0.0967273051 [21] -0.1036306228 -0.1023182704 -0.0461991150 0.0776955854 -0.0706633860 [26] -0.0134182535 0.0081739386 -0.0942477346 0.0958833327 0.0279310224 [31] -0.0399173724 -0.0413556774 -0.0824676524 -0.0005781247 0.0800317960 [36] -0.0113486615 0.0618381583 -0.0327280371 0.0692522529 0.0404170201 [41] -0.0190372749 -0.0932502518 0.0343220765 0.0533993716 -0.0035318588 [46] 0.0146697800 0.0100013089 -0.0700901124 0.0442766063 0.0009757731 [51] 0.0082251986 0.1147454927 0.0384061661 0.0222836106 -0.1133109905 [56] -0.0109029197 0.0125426598 -0.0453767731 0.0247636002 -0.0774570261 > 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/4rssf1377083497.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/5va5v1377083497.tab") > > try(system("convert tmp/1f6dy1377083497.ps tmp/1f6dy1377083497.png",intern=TRUE)) character(0) > try(system("convert tmp/2st1s1377083497.ps tmp/2st1s1377083497.png",intern=TRUE)) character(0) > try(system("convert tmp/30a8t1377083497.ps tmp/30a8t1377083497.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.636 0.316 1.937