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(2.58,2.59,2.6,2.6,2.61,2.62,2.64,2.65,2.66,2.67,2.68,2.69,2.69,2.71,2.72,2.73,2.73,2.74,2.74,2.74,2.74,2.74,2.75,2.75,2.75,2.75,2.77,2.78,2.79,2.8,2.82,2.83,2.84,2.87,2.89,2.9,2.9,2.91,2.92,2.92,2.92,2.92,2.94,2.95,2.95,2.97,2.99,3,3,3.01,3.03,3.03,3.04,3.04,3.05,3.05,3.09,3.09,3.09,3.1,3.1,3.11,3.12,3.12,3.12,3.13,3.15,3.16,3.16,3.18,3.19,3.19,3.2,3.21,3.26,3.27,3.28,3.29,3.29,3.3,3.3,3.31,3.31,3.31) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/12a831400777287.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/2guec1400777287.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/3y5tj1400777287.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.001436921 -0.028968413 -0.012892199 0.119471230 [6] 0.046580719 -0.229812420 0.017086912 -0.084875404 -0.085086405 [11] -0.135910367 -0.077977760 -0.047365645 0.039638765 -0.149538961 [16] -0.093357669 0.040757074 -0.046669339 0.083942776 0.027339481 [21] 0.175990125 -0.067828582 -0.053503682 0.078859747 0.125759078 [26] -0.032595531 -0.149093748 -0.016730319 0.108627856 0.066560463 [31] -0.109832676 -0.079220560 0.124071065 -0.081393877 -0.085107505 [36] -0.070782605 0.063332138 0.004977528 -0.156879708 0.148163231 [41] 0.078775347 0.167531070 0.003922520 0.107214146 0.066898065 [46] -0.035064250 0.006581141 -0.037237567 0.067805372 > (mypacf <- c(rpacf$acf)) [1] -1.436921e-03 -2.897054e-02 -1.298759e-02 1.187088e-01 4.679549e-02 [6] -2.271173e-01 2.385216e-02 -1.111706e-01 -1.084100e-01 -9.397030e-02 [11] -7.688449e-02 -1.000436e-01 7.444019e-02 -1.895598e-01 -1.277527e-01 [16] -9.774464e-03 -1.529512e-01 3.666436e-02 5.125848e-02 5.490927e-02 [21] -1.201885e-01 -1.019130e-01 -5.228596e-02 8.275224e-02 -8.485562e-02 [26] -1.422481e-01 -7.941235e-02 6.550977e-02 5.478547e-02 -4.396213e-02 [31] -1.693299e-01 7.205939e-02 -1.494864e-01 -3.832885e-02 -5.587733e-02 [36] -9.100151e-02 -7.704544e-02 -1.544189e-01 1.003889e-01 2.923915e-02 [41] 1.308823e-01 -3.929971e-02 1.115131e-01 -8.034740e-03 3.784001e-03 [46] 2.588779e-02 -6.260302e-02 7.938736e-05 > 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/4luzl1400777287.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/5lat31400777287.tab") > > try(system("convert tmp/12a831400777287.ps tmp/12a831400777287.png",intern=TRUE)) character(0) > try(system("convert tmp/2guec1400777287.ps tmp/2guec1400777287.png",intern=TRUE)) character(0) > try(system("convert tmp/3y5tj1400777287.ps tmp/3y5tj1400777287.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.529 0.329 1.868