R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" 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(16.68,16.68,16.69,16.61,16.58,16.6,16.6,16.62,16.62,16.6,16.63,16.66,16.66,16.65,16.5,16.39,16.34,16.35,16.35,16.38,16.36,16.38,16.39,16.41,16.41,16.41,16.45,16.41,16.44,16.47,16.47,16.49,16.54,16.62,16.69,16.72,16.72,16.71,16.89,16.93,16.91,16.93,16.93,16.93,16.95,16.93,16.95,16.95,16.95,16.95,16.92,16.91,16.9,16.96,16.96,16.95,16.92,16.87,16.87,16.88,16.88,16.86,16.88,16.88,16.88,16.88,16.88,16.87,16.92,16.94,17.03,17.02,17.02,17.02,16.99,17.03,16.98,16.89,16.89,16.9,16.89,16.96,16.97,16.97) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/wessaorg/rcomp/tmp/1k3vx1384953550.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/2c47u1384953550.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/3vc0a1384953550.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.283077876 0.072603848 0.041653550 -0.049878669 [6] 0.115708011 0.114231132 -0.080336473 -0.069805972 -0.010248137 [11] 0.073877869 0.086353699 0.061214235 0.022365228 -0.096795702 [16] 0.072136609 -0.026774446 -0.072792663 -0.244083394 -0.179410683 [21] -0.070020548 0.015983707 -0.055055473 -0.222170453 -0.234782666 [26] -0.104480239 -0.024253277 0.043765065 0.017233684 -0.063792079 [31] -0.028383162 0.005491293 0.067623336 -0.024017889 0.019323277 [36] -0.070506780 0.071383774 0.119772735 -0.128081806 -0.164566231 [41] 0.021865662 0.048713452 0.079250660 0.056685403 -0.045009486 [46] -0.057831325 0.017238836 0.080938882 -0.004748964 0.045308620 [51] -0.028967185 0.006056020 0.021558850 0.016459634 -0.093586757 [56] -0.093185386 -0.083526930 0.024857000 0.034792162 0.018943323 [61] 0.046000740 > (mypacf <- c(rpacf$acf)) [1] 0.283077876 -0.008185136 0.025276885 -0.073771756 0.162164746 [6] 0.044012041 -0.143534461 -0.030890244 0.048870875 0.087412711 [11] -0.001008726 0.038394174 0.029214009 -0.121890078 0.117221847 [16] -0.107852810 -0.037658644 -0.277576243 0.035564350 -0.008544281 [21] 0.023866359 -0.108936156 -0.183565448 -0.080266199 -0.048666829 [26] -0.004047756 0.039759489 0.042991698 0.039605295 -0.033770191 [31] 0.045687746 -0.005678134 -0.014850172 0.065124478 -0.050673106 [36] 0.119407369 -0.002316753 -0.224678219 -0.146551277 0.102196338 [41] -0.022009560 -0.162707359 -0.006926946 0.036223812 -0.081168318 [46] -0.076449255 0.022981370 -0.030283407 -0.006568419 0.077473401 [51] 0.128531952 -0.047630717 -0.039315421 -0.053521678 -0.010086175 [56] -0.158322248 0.010187575 0.030475196 0.060554731 0.086813575 > 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/4ayni1384953550.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/5mkbu1384953550.tab") > > try(system("convert tmp/1k3vx1384953550.ps tmp/1k3vx1384953550.png",intern=TRUE)) character(0) > try(system("convert tmp/2c47u1384953550.ps tmp/2c47u1384953550.png",intern=TRUE)) character(0) > try(system("convert tmp/3vc0a1384953550.ps tmp/3vc0a1384953550.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.859 0.397 2.236