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(85.73,85.73,85.74,86.32,87.59,87.81,87.87,87.94,87.96,88.01,88.01,88.01,88.01,88.01,88.59,89.43,89.63,89.73,89.88,89.89,89.9,89.91,89.86,90.07,90.17,90.17,90.28,90.87,92.05,92.1,92.16,92.22,92.25,92.29,92.29,92.29,92.29,92.29,91.95,91.82,92.16,92.31,92.33,92.4,92.54,92.49,92.54,92.58,92.58,92.39,92.33,93.59,95.51,95.99,96.22,97.2,98.54,99.64,100.23,100.17) > 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/18czp1387734636.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/2gov81387734636.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/3zruh1387734636.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.907183266 0.799204179 0.693304707 0.601238274 [6] 0.530151355 0.467139606 0.404174650 0.347288020 0.315341710 [11] 0.299412465 0.280809706 0.256066194 0.227288802 0.196392668 [16] 0.169758536 0.148545570 0.129683330 0.112322102 0.096828174 [21] 0.083295485 0.073902448 0.062599441 0.045842252 0.027118960 [26] 0.002028988 -0.027609196 -0.058444244 -0.086615650 -0.108854251 [31] -0.134086704 -0.160398942 -0.186349200 -0.197149560 -0.200565975 [36] -0.202620540 -0.204936071 -0.208730612 -0.214308415 -0.226396707 [41] -0.241090302 -0.255229727 -0.270946170 -0.287364132 -0.303828341 [46] -0.317117670 -0.319694586 -0.314663622 -0.312453501 > (mypacf <- c(rpacf$acf)) [1] 0.9071832664 -0.1343209708 -0.0417215052 0.0148345722 0.0512554404 [6] -0.0181205473 -0.0454957723 0.0017015139 0.1081578784 0.0464531668 [11] -0.0460793726 -0.0336662098 -0.0048849329 -0.0145061011 -0.0050359934 [16] 0.0019861011 0.0066848931 0.0068332976 -0.0046953266 -0.0096918138 [21] 0.0082387223 -0.0238272904 -0.0369978038 -0.0122780220 -0.0448998255 [26] -0.0451513381 -0.0349692793 -0.0159305439 -0.0006057144 -0.0598470291 [31] -0.0464397195 -0.0306042760 0.0521123413 -0.0102214755 -0.0305294786 [36] -0.0121394056 -0.0022438548 -0.0253455239 -0.0725055130 -0.0405624538 [41] -0.0032886399 -0.0295618223 -0.0483369486 -0.0422682191 -0.0146986546 [46] 0.0221300031 -0.0052057735 -0.0535166658 > 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/4qrtm1387734636.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/5bxyk1387734636.tab") > > try(system("convert tmp/18czp1387734636.ps tmp/18czp1387734636.png",intern=TRUE)) character(0) > try(system("convert tmp/2gov81387734636.ps tmp/2gov81387734636.png",intern=TRUE)) character(0) > try(system("convert tmp/3zruh1387734636.ps tmp/3zruh1387734636.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.503 0.516 2.991