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(1.464,1.474,1.479,1.517,1.575,1.627,1.613,1.558,1.545,1.406,1.269,1.191,1.231,1.276,1.281,1.312,1.363,1.419,1.374,1.422,1.378,1.38,1.409,1.398,1.445,1.452,1.506,1.531,1.524,1.52,1.499,1.491,1.496,1.493,1.507,1.569,1.593,1.597,1.633,1.686,1.683,1.646,1.658,1.636,1.67,1.634,1.618,1.622,1.688,1.723,1.776,1.809,1.754,1.714,1.733,1.783,1.818,1.81,1.764,1.73,1.742,1.785,1.769,1.743,1.721,1.73,1.753,1.764,1.758,1.7,1.678,1.688) > 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/1zcba1418912808.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/246r71418912808.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/3pfr61418912808.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.95958200 0.89291164 0.81967278 0.75417321 0.70109697 [7] 0.66082422 0.63696697 0.61904736 0.61035204 0.59071516 0.55600673 [13] 0.50276010 0.44077087 0.37588304 0.31432189 0.26342607 0.21927549 [19] 0.18530651 0.15054974 0.11823794 0.07810660 0.03587784 -0.01199686 [25] -0.06801945 -0.11539248 -0.15633652 -0.18742943 -0.21637030 -0.23482985 [31] -0.24901451 -0.25942982 -0.27697871 -0.30056829 -0.32243134 -0.34735246 [37] -0.37309375 -0.39943008 -0.41836836 -0.42989400 -0.43274077 -0.42636978 [43] -0.41469204 -0.40354296 -0.39795758 -0.39326638 -0.38653335 -0.37412206 [49] -0.35893265 > (mypacf <- c(rpacf$acf)) [1] 0.959582004 -0.352085119 -0.013963997 0.091292072 0.062975963 [6] 0.053899546 0.129156237 -0.037078637 0.119523874 -0.199920145 [11] -0.092769429 -0.140295662 -0.008235479 -0.076514202 0.003864473 [16] -0.012450062 -0.043180702 -0.010108111 -0.110458430 0.025045072 [21] -0.104962412 0.053866766 -0.096525007 -0.089116688 0.107118713 [26] -0.033025634 -0.035524634 -0.037108801 0.080350299 -0.007552740 [31] 0.041213597 -0.166134481 0.065614110 0.025704401 -0.078315747 [36] -0.124289855 0.027106709 -0.021728337 0.028646112 -0.057525339 [41] 0.078165676 0.047372223 -0.077119571 -0.037752348 0.015647529 [46] 0.139684895 0.025717254 -0.040462804 > 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/4q4iy1418912808.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/5b2dl1418912808.tab") > > try(system("convert tmp/1zcba1418912808.ps tmp/1zcba1418912808.png",intern=TRUE)) character(0) > try(system("convert tmp/246r71418912808.ps tmp/246r71418912808.png",intern=TRUE)) character(0) > try(system("convert tmp/3pfr61418912808.ps tmp/3pfr61418912808.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.228 0.202 1.434