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(250.8,247.6,237.8,226.4,217.2,211.4,207.6,204.3,197.5,193.6,192.3,192,196.1,191.9,185.6,179.4,173.9,169.2,166.8,165.2,161.4,160.8,163.7,170.8,182.7,190.9,197.8,205.1,210.7,220.2,229.7,237.1,241.6,250.4,258.6,269.9,283.2,289.6,281.8,274.7,267.6,261.4,260.5,260.7,254.2,250.5,253.4,263.7,276.2,273.8,265.9,258.4,253.5,250.7,252.8,255.3,251.2,252.5,257.8,269.9,291.6,298.9,295.6,292.1,290.9,290.6,298,304,304.3,309.8,322.3,340.2,369.3,376.7,379.7,379.5,377.8,381.6,394.6,399.3,400.4,408.2,419.1,437.7) > 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/1ny7g1413483579.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/21wqq1413483579.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/3ojkc1413483579.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.9534814803 0.9052299528 0.8560860690 0.8073207393 [6] 0.7566865005 0.7045551844 0.6541658009 0.6034025434 0.5515579086 [11] 0.4991949004 0.4458946430 0.3900485379 0.3405782979 0.2952321318 [16] 0.2551021601 0.2192656155 0.1859396229 0.1562996987 0.1304337526 [21] 0.1062213428 0.0845491916 0.0640541061 0.0430504874 0.0233982750 [26] 0.0105341064 0.0019178705 -0.0031678150 -0.0051848615 -0.0066099596 [31] -0.0055115731 -0.0029785507 -0.0007490605 0.0009325610 0.0003110836 [36] -0.0047176535 -0.0145217815 -0.0231958044 -0.0303614052 -0.0380302573 [41] -0.0482350400 -0.0621626082 -0.0775757104 -0.0951669966 -0.1167399637 [46] -0.1422498598 -0.1721152659 -0.2076253262 -0.2432954627 > (mypacf <- c(rpacf$acf)) [1] 0.9534814803 -0.0428837785 -0.0348255492 -0.0219636409 -0.0476851574 [6] -0.0447829739 -0.0103920793 -0.0351880834 -0.0436442936 -0.0379057333 [11] -0.0455829945 -0.0655447892 0.0330037499 0.0077495539 0.0204546031 [16] 0.0152683193 -0.0063314957 0.0055367858 0.0126292430 -0.0113299493 [21] -0.0006255442 -0.0150682769 -0.0368800515 -0.0192767765 0.0483898450 [26] 0.0214790662 0.0222055741 0.0230196110 -0.0086666044 0.0166433777 [31] 0.0127715141 -0.0099969297 -0.0095878684 -0.0311694136 -0.0641236155 [36] -0.0707235915 0.0027021310 0.0078030613 -0.0068170922 -0.0255502936 [41] -0.0493771986 -0.0227817443 -0.0258811198 -0.0505621534 -0.0519588470 [46] -0.0689910004 -0.1027533714 -0.0516333485 > 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/4pd0s1413483579.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/5nox61413483579.tab") > > try(system("convert tmp/1ny7g1413483579.ps tmp/1ny7g1413483579.png",intern=TRUE)) character(0) > try(system("convert tmp/21wqq1413483579.ps tmp/21wqq1413483579.png",intern=TRUE)) character(0) > try(system("convert tmp/3ojkc1413483579.ps tmp/3ojkc1413483579.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.208 0.195 1.414