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.33,1.32,1.32,1.4,1.43,1.43,1.45,1.45,1.33,1.27,1.27,1.29,1.25,1.26,1.32,1.36,1.4,1.41,1.42,1.39,1.38,1.41,1.47,1.44,1.47,1.45,1.47,1.49,1.54,1.61,1.63,1.55,1.53,1.41,1.26,1.19,1.17,1.21,1.24,1.26,1.32,1.39,1.35,1.41,1.37,1.32,1.38,1.38,1.41,1.4,1.45,1.49,1.51,1.48,1.47,1.46,1.46,1.45,1.47,1.53,1.55,1.55,1.6,1.65,1.68,1.63,1.62,1.63,1.66,1.63,1.6,1.6) > 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/1ddl51352741005.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/2s1gr1352741005.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/32x6b1352741005.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.9151239906 0.7790355162 0.6220627335 0.4634748568 [6] 0.3264046089 0.2297778377 0.1797497043 0.1516537827 0.1162708627 [11] 0.0891872362 0.0668166316 0.0132785304 -0.0477525891 -0.1004081115 [16] -0.1442531060 -0.1785270796 -0.1965738108 -0.1940541654 -0.1768282637 [21] -0.1612505207 -0.1254294200 -0.0856990290 -0.0558296128 -0.0500060195 [26] -0.0508666257 -0.0761393124 -0.1126032007 -0.1535410262 -0.1685890240 [31] -0.1397497071 -0.0994801037 -0.0354571747 0.0428091018 0.1139079224 [36] 0.1604217077 0.1945412370 0.2052202858 0.1937738202 0.1614048943 [41] 0.1179821133 0.0770722658 0.0359411377 0.0008685192 -0.0148204293 [46] -0.0294792785 -0.0560542140 -0.0832497526 -0.1205529810 > (mypacf <- c(rpacf$acf)) [1] 0.915123991 -0.359379214 -0.128440491 -0.061945447 0.041241550 [6] 0.106980776 0.106905141 -0.066309755 -0.175214364 0.066601660 [11] 0.038326592 -0.227553836 0.009539344 0.029368789 -0.040139890 [16] -0.013757423 0.023481237 -0.029678529 0.009283240 0.011306906 [21] 0.129558470 -0.065062861 -0.011341862 -0.120954420 0.031287964 [26] -0.147500277 0.022062056 -0.048816997 0.100829250 0.190514292 [31] -0.076034337 0.053314203 0.054498682 0.036816357 -0.003598852 [36] 0.096655094 -0.070324846 -0.087400928 0.017996157 -0.104283069 [41] -0.071330207 0.007240696 0.001070263 -0.012737641 -0.028218295 [46] -0.119246737 0.020050742 -0.086845351 > 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/4rrxx1352741005.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/5laqv1352741005.tab") > > try(system("convert tmp/1ddl51352741005.ps tmp/1ddl51352741005.png",intern=TRUE)) character(0) > try(system("convert tmp/2s1gr1352741005.ps tmp/2s1gr1352741005.png",intern=TRUE)) character(0) > try(system("convert tmp/32x6b1352741005.ps tmp/32x6b1352741005.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.950 0.312 2.276