R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(660,770,792,693,726,814,770,737,792,693,770,847,627,704,792,693,770,770,737,836,957,737,891,891,671,660,803,693,825,847,726,869,979,748,880,946,737,671,759,748,814,836,737,825,979,803,825,1034,814,704,704,825,847,858,704,803,1067,858,792,1155,869,671,583,825,803,957,737,825,1199,913,814,1111,858,704,649,847,715,968,770,869,1254,946,693,1166,924,792,627,869,627,880,869,858,1232,935,660,1155,891,825,605,814,550,825,902,891,1199,902,693,1188) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/12tv31408118440.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/2ywv81408118440.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/3cvo81408118440.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.388066464 -0.291052658 0.323253570 -0.017877413 [6] -0.201767974 0.183632453 -0.190128993 -0.036950808 0.311033245 [11] -0.215858640 -0.418419836 0.824771561 -0.242076316 -0.326100702 [16] 0.296089936 0.032999028 -0.214682137 0.147333729 -0.128888888 [21] -0.062239415 0.273142052 -0.131226607 -0.395493374 0.610222531 [26] -0.081402801 -0.332754383 0.247470050 0.079801480 -0.210443882 [31] 0.084184082 -0.038480716 -0.111111250 0.241365953 -0.045962006 [36] -0.357116926 0.409064528 0.025767537 -0.283260406 0.176300240 [41] 0.098752294 -0.190687905 0.043260424 0.029604259 -0.147607509 [46] 0.210784136 0.006156612 -0.297385685 0.244520853 > (mypacf <- c(rpacf$acf)) [1] -0.3880664639 -0.5199504834 -0.0809927342 -0.0166703326 -0.0968599366 [6] 0.0531586059 -0.2910690880 -0.2725533253 0.0634310287 -0.0271793443 [11] -0.6492173576 0.4332853400 0.1605526935 0.0851898742 -0.0165203447 [16] 0.0519229565 0.0057155690 -0.1436914040 0.0002497602 0.0008841025 [21] -0.0537064359 -0.0264282057 0.1079455567 -0.1664699541 -0.0068078137 [26] 0.0266367266 0.0707573657 -0.0061054470 0.0095009579 -0.0763244473 [31] 0.0162447569 -0.0877702558 0.0379069837 0.0583944941 0.0470220941 [36] -0.0536450677 -0.1243713065 0.0891174509 0.0303187015 -0.0250181087 [41] -0.0786928802 0.0318153015 -0.0422512265 -0.0250760744 0.0897127586 [46] 0.0058353417 -0.0195698686 -0.0723094127 > 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/4hyrp1408118440.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/5w5jc1408118440.tab") > > try(system("convert tmp/12tv31408118440.ps tmp/12tv31408118440.png",intern=TRUE)) character(0) > try(system("convert tmp/2ywv81408118440.ps tmp/2ywv81408118440.png",intern=TRUE)) character(0) > try(system("convert tmp/3cvo81408118440.ps tmp/3cvo81408118440.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.168 0.209 1.388