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(44.91,44.86,44.76,44.89,44.89,45,45.01,45.11,45.05,44.67,44.48,44.48,44.48,44.58,44.79,44.79,44.41,44.41,44.44,44.43,44.36,44.39,44.39,44.41,44.32,44.43,44.82,44.97,44.91,44.79,44.76,44.8,44.65,44.49,44.56,44.4,44.45,44.46,44.39,44.5,44.44,44.41,44.4,44.42,44.49,44.46,44.49,44.5,44.5,44.5,44.55,44.53,44.49,44.49,44.62,44.59,44.56,44.57,44.04,44.06,44.07,44.1,44.21,44.48,44.51,44.24,44.25,44.27,44.45,44.39,44.23,44.23) > 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/1zr101414091188.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/2a5q41414091188.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/3jlm71414091188.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.815161125 0.591247909 0.446684081 0.337379363 [6] 0.261697746 0.209344159 0.179958593 0.114404982 0.032009569 [11] -0.021447577 -0.010693900 0.015082371 0.009393248 -0.037517838 [16] -0.071742191 -0.089946949 -0.049180354 0.019813229 0.081207949 [21] 0.141269187 0.178766786 0.222689770 0.262244568 0.254875735 [26] 0.245985180 0.214319551 0.137988505 0.056568916 -0.018322427 [31] -0.102080566 -0.166118505 -0.207631797 -0.200737384 -0.175440117 [36] -0.146769986 -0.094494169 -0.084790268 -0.097869173 -0.102994247 [41] -0.076641153 -0.033252637 -0.010355772 -0.047427598 -0.070066091 [46] -0.038484955 0.005905268 0.022716926 0.049064977 > (mypacf <- c(rpacf$acf)) [1] 0.815161125 -0.218292272 0.117225677 -0.048603048 0.044217473 [6] -0.001074394 0.043005225 -0.142718622 -0.040598104 -0.003137484 [11] 0.125149992 -0.011186399 -0.049832116 -0.124823842 0.045098658 [16] -0.020457565 0.185008521 0.003009205 0.055460573 0.062882909 [21] 0.073478275 0.109166655 0.041760922 -0.135856082 0.070332394 [26] -0.086328488 -0.051151713 -0.068289541 -0.091555186 -0.188527932 [31] 0.029337251 -0.072341972 0.152716092 -0.038102124 0.085446459 [36] 0.095523321 -0.046517803 -0.017431198 0.049858958 -0.036844620 [41] 0.064973723 -0.098315370 -0.239726729 0.024721142 0.042038946 [46] -0.021667435 -0.050677982 0.006670774 > 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/46w3x1414091188.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/5yvmz1414091188.tab") > > try(system("convert tmp/1zr101414091188.ps tmp/1zr101414091188.png",intern=TRUE)) character(0) > try(system("convert tmp/2a5q41414091188.ps tmp/2a5q41414091188.png",intern=TRUE)) character(0) > try(system("convert tmp/3jlm71414091188.ps tmp/3jlm71414091188.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.165 0.206 1.387