R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(1120,1120,1190,1190,1190,1190,1070,1200,1090,1130,1140,1240,1180,1080,1190,1140,1160,1200,980,1260,1100,1210,1150,1140,1110,1120,1100,1170,1120,1250,910,1260,1090,1240,1130,1200,1120,1120,1120,1070,1100,1230,930,1240,980,1270,1140,1160,1160,1220,1160,1090,1060,1230,1070,1240,1050,1350,1100,1130,1170,1360,1150,1180,1010,1190,1000,1270,990,1470,1130,1150,1150,1410,1190,1180,990,1170,1080,1350,960,1490,1120,1090,1220,1370,1180,1190,1000,1250,1090,1370,980,1530,1150,1120,1290,1370,1130,1200,910,1220,1040,1340,950,1500,1120,1150) > 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/1kjph1342174292.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/2y1k31342174292.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/3p2xa1342174292.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.00000000 -0.48586785 0.36915732 -0.34715096 0.32973693 -0.27895616 [7] 0.22803224 -0.28285057 0.34352128 -0.27913050 0.30379338 -0.43184561 [13] 0.79924255 -0.43294521 0.32268127 -0.30760038 0.27306210 -0.20808661 [19] 0.18144146 -0.27923402 0.29423741 -0.23919080 0.26601166 -0.35656089 [25] 0.61928832 -0.37953527 0.29423255 -0.29607366 0.21524830 -0.16836690 [31] 0.11803093 -0.26285569 0.23778612 -0.20856637 0.23834118 -0.29464824 [37] 0.43554458 -0.32791246 0.27102218 -0.27195784 0.15459829 -0.11489428 [43] 0.07045493 -0.19570822 0.15695146 -0.16872010 0.18613357 -0.23344286 [49] 0.25158441 > (mypacf <- c(rpacf$acf)) [1] -0.485867850 0.174216650 -0.154426502 0.115229949 -0.041831653 [6] 0.005836621 -0.125226445 0.160910871 -0.012299756 0.094654580 [11] -0.242377078 0.707798165 0.178619217 -0.184464208 0.126786911 [16] -0.011430991 0.060699596 -0.018909185 -0.104703923 -0.090964652 [21] -0.078056277 0.055708233 0.075384392 -0.088479802 -0.062607529 [26] 0.079683207 -0.032334025 -0.066166228 -0.025705072 -0.138912520 [31] -0.077621074 -0.026442609 -0.027527440 -0.007626684 -0.023697748 [36] -0.131147825 -0.045153544 0.082801317 0.024189790 -0.099558979 [41] 0.026141304 0.047515107 0.097882578 -0.018081062 -0.008751162 [46] -0.052870440 -0.056919673 -0.098224950 > 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/47u3v1342174292.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/5maqy1342174292.tab") > > try(system("convert tmp/1kjph1342174292.ps tmp/1kjph1342174292.png",intern=TRUE)) character(0) > try(system("convert tmp/2y1k31342174292.ps tmp/2y1k31342174292.png",intern=TRUE)) character(0) > try(system("convert tmp/3p2xa1342174292.ps tmp/3p2xa1342174292.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.119 0.240 1.353