R version 3.1.0 (2014-04-10) -- "Spring Dance" Copyright (C) 2014 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(1.005,1.026,1.043,1.068,1.07,1.091,1.102,1.091,1.121,1.134,1.225,1.191,1.184,1.207,1.271,1.299,1.411,1.437,1.462,1.36,1.33,1.234,1.142,1.017,1.016,1.013,1,1.018,1.024,1.075,1.055,1.091,1.062,1.083,1.099,1.097,1.138,1.138,1.181,1.223,1.23,1.232,1.209,1.209,1.218,1.225,1.242,1.294,1.33,1.357,1.407,1.42,1.386,1.377,1.393,1.371,1.393,1.405,1.438,1.424,1.47,1.481,1.506,1.503,1.478,1.433,1.459,1.51,1.526,1.543,1.529,1.499) > 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/1ziwi1400503062.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/204pk1400503062.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/33aov1400503062.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.94248051 0.86425990 0.76521322 0.66988645 0.57280544 [7] 0.49586567 0.43046482 0.36438838 0.30284691 0.24589905 0.20231892 [13] 0.15179527 0.10500365 0.06119559 0.03395520 0.01554114 0.02157845 [19] 0.03413192 0.05606042 0.06100979 0.05702807 0.03853574 0.01151480 [25] -0.03264988 -0.07000093 -0.09637760 -0.11651602 -0.12666976 -0.13100059 [31] -0.13194066 -0.14189017 -0.15316876 -0.17100047 -0.18923157 -0.20438437 [37] -0.21825100 -0.22176869 -0.22230029 -0.21545503 -0.19628127 -0.18319334 [43] -0.16607485 -0.15948599 -0.14785551 -0.13831211 -0.12521446 -0.11380422 [49] -0.09439142 > (mypacf <- c(rpacf$acf)) [1] 0.9424805134 -0.2148886748 -0.2049680650 0.0340788608 -0.0644932941 [6] 0.1163628403 0.0136962996 -0.1454893299 0.0013114717 -0.0016402714 [11] 0.0762397660 -0.1302701152 -0.0464019074 0.0154435412 0.1087358945 [16] 0.0453059269 0.1250021985 -0.0587576552 0.0351299384 -0.1428969048 [21] -0.0432127037 -0.0593040629 -0.0472717759 -0.1492829621 0.0936127073 [26] 0.0605967988 0.0036515066 0.0008164271 -0.0159293606 -0.0453031922 [31] -0.0108026760 -0.0177657009 -0.0327926235 -0.0646200296 0.0758287172 [36] -0.1052141558 0.0455142264 -0.0810657110 0.0225364746 0.1023073584 [41] -0.0935306144 0.0789659145 -0.0390252977 0.0660546896 0.0433928968 [46] -0.0611064393 -0.0283214615 0.0175915001 > 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/4lpfw1400503062.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/52ccp1400503062.tab") > > try(system("convert tmp/1ziwi1400503062.ps tmp/1ziwi1400503062.png",intern=TRUE)) character(0) > try(system("convert tmp/204pk1400503062.ps tmp/204pk1400503062.png",intern=TRUE)) character(0) > try(system("convert tmp/33aov1400503062.ps tmp/33aov1400503062.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.645 0.325 1.979