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(37.3,39.5,40.6,41.4,41.3,43.5,44,44.9,46.4,47.4,48.7,49.7,51.1,53.2,56.2,58.1,60.6,64.1,67.4,68,70.9,72.8,74.9,76.1,77,78.1,80,79.7,82.7,84.3,83.5,85.9,87,88.6,90.6,91.3,91.6,93.2,95,95.2,97.4,98.6,99.6,100.6,101.3,102.8,103.2,103,105.4,104.7,105.2,105.2,102.8,100.3,99.8,99.4,100.6,100.2,100.4,98.8,96.9,96.3,96.1,93.5,92.1,91.7,87.9,86.4,84.9,81.7,82.6,83.1) > 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/146881413628450.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/29gyf1413628450.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/397jc1413628450.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.96741433 0.93418729 0.89884910 0.86007352 0.81791599 [7] 0.77541807 0.72963179 0.68212220 0.63341816 0.58308020 0.53202789 [13] 0.47965813 0.42669034 0.37420299 0.32325372 0.27285377 0.22387972 [19] 0.17746990 0.13474997 0.09148744 0.05057983 0.01175360 -0.02509029 [25] -0.06129835 -0.09664465 -0.13104932 -0.16310738 -0.19601118 -0.22519937 [31] -0.25191516 -0.28011312 -0.30474512 -0.32732808 -0.34767588 -0.36475814 [37] -0.37976044 -0.39395898 -0.40523467 -0.41290525 -0.41968390 -0.42254812 [43] -0.42258055 -0.42058011 -0.41605682 -0.40925311 -0.39928160 -0.38715303 [49] -0.37401157 > (mypacf <- c(rpacf$acf)) [1] 0.9674143289 -0.0265669119 -0.0500373891 -0.0718225259 -0.0723563820 [6] -0.0251846810 -0.0704970285 -0.0488329676 -0.0425701970 -0.0506109482 [11] -0.0366460820 -0.0506237396 -0.0403365160 -0.0251419801 -0.0100372738 [16] -0.0256167691 -0.0164664071 0.0004755273 0.0188325225 -0.0491006280 [21] -0.0102052288 -0.0138996373 -0.0139553478 -0.0355529931 -0.0397195028 [26] -0.0344558561 -0.0127346976 -0.0627389558 0.0076519784 -0.0097230305 [31] -0.0702302008 0.0082374629 -0.0175703160 -0.0075402427 0.0088758379 [36] -0.0140770163 -0.0274674879 -0.0041539570 0.0155293341 -0.0260029668 [41] 0.0165821778 0.0015456472 -0.0049158240 0.0013848285 -0.0052045241 [46] 0.0161465890 0.0070882312 -0.0172783352 > 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/49hd51413628450.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/55evm1413628450.tab") > > try(system("convert tmp/146881413628450.ps tmp/146881413628450.png",intern=TRUE)) character(0) > try(system("convert tmp/29gyf1413628450.ps tmp/29gyf1413628450.png",intern=TRUE)) character(0) > try(system("convert tmp/397jc1413628450.ps tmp/397jc1413628450.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.139 0.199 1.348