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(770,710,890,730,790,820,810,810,760,840,830,890,800,710,850,790,800,840,850,810,760,860,860,880,770,740,850,790,860,820,900,800,660,820,850,850,760,730,770,880,890,790,930,770,680,810,870,850,820,740,800,920,970,780,880,750,620,760,930,820,900,700,810,970,820,740,930,720,580,800,910,810,890,710,830,900,830,680,980,690,530,740,930,770,870,660,770,900,830,660,1000,710,460,740,940,870,810,650,760,950,870,670,960,750,480,690,850,890) > 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/13nhl1408362706.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/2v0vz1408362706.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/3b0481408362706.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.2849916464 -0.4057069872 0.1936659604 0.0506857576 [6] -0.1882275667 0.2462423582 -0.1419896188 0.0284467805 0.2012139392 [11] -0.3690445944 -0.2407501037 0.7890370075 -0.1774649961 -0.3444725067 [16] 0.1291908352 0.0668091721 -0.1773335351 0.2127567185 -0.0938083791 [21] -0.0048465760 0.1744366455 -0.2947716986 -0.1817160972 0.5901505653 [26] -0.1090459543 -0.2641054029 0.0736721516 0.0610765510 -0.1332598770 [31] 0.1463318062 -0.0537299876 0.0231175275 0.0954432436 -0.2355880886 [36] -0.1007990995 0.3989388267 -0.0315096359 -0.2117909739 0.0364315993 [41] 0.0530895447 -0.0880217377 0.0718467255 0.0023025148 0.0320244833 [46] 0.0271808590 -0.1629442085 -0.0693734500 0.2849826864 -0.0074868879 [51] -0.1479705545 0.0041688446 0.0348423452 -0.0299379155 -0.0007959413 [56] 0.0296520310 0.0392705260 -0.0070262917 -0.0720868905 -0.0929084363 [61] 0.1915527729 > (mypacf <- c(rpacf$acf)) [1] -0.2849916464 -0.5299716495 -0.2032194679 -0.2413677326 -0.3586532464 [6] -0.0094479087 -0.3306431462 0.0167301701 0.1964876289 -0.2916508610 [11] -0.6562975524 0.1714781677 0.0316899927 0.2016469398 0.0006404575 [16] 0.0372932799 0.0423469744 0.0291007952 0.1078141522 -0.0231337483 [21] -0.0799855991 -0.0754293735 0.0563822327 0.0206702139 -0.0444257505 [26] 0.0232078508 -0.0249206352 0.0165365643 0.0857599836 -0.0593168937 [31] -0.0342550940 0.0617729143 -0.0153095319 -0.0151586122 -0.0082072961 [36] -0.1182968967 0.0327964931 -0.0689414313 0.0054586528 -0.0407006080 [41] -0.0315772935 -0.0412207491 0.0448494575 -0.0058174713 -0.0429698342 [46] 0.0413288025 -0.0584997927 0.0803345296 -0.0429862611 0.0128955204 [51] -0.0019694397 -0.0386922162 0.0767798269 -0.0321885379 -0.0320126881 [56] -0.1161745113 -0.0682255935 0.1678207719 -0.0355357030 0.0100622410 > 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/4i1991408362706.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/5zcrc1408362706.tab") > > try(system("convert tmp/13nhl1408362706.ps tmp/13nhl1408362706.png",intern=TRUE)) character(0) > try(system("convert tmp/2v0vz1408362706.ps tmp/2v0vz1408362706.png",intern=TRUE)) character(0) > try(system("convert tmp/3b0481408362706.ps tmp/3b0481408362706.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.155 0.189 1.355