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(2.04,2.08,1.94,1.91,1.34,1.3,1.39,1.23,1.3,1.79,2.25,2.63,2.8,3.08,3.89,3.68,4.62,5.07,5.22,4.94,5.14,4.8,3.89,3.54,3.34,2.8,1.6,1.56,0.68,-0.11,-0.66,-0.2,-0.62,-0.59,-0.3,-0.26,-0.08,0.13,0.94,1.05,1.59,2.03,2.15,2.05,2.56,2.54,2.53,2.6,2.71,2.82,2.92,2.87,2.89,3.27,3.32,3.14,3.04,3.09,3.39,3.24,3.38,3.41,3.14,2.96,2.74,2.21,2.24,2.56,2.39,2.49,2.17,2.16,1.48,1.09,1.25,1.27,1.39,1.69,1.55,1.19,1.08,0.94,0.98,1.01) > 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/1op851413725950.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/2g8xh1413725950.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/3uh9r1413725950.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.342643706 0.341096001 0.379660895 0.338944717 [6] -0.021744780 0.076616085 0.193713262 -0.089875375 -0.194015595 [11] -0.227314525 -0.173056741 -0.611807764 -0.245895955 -0.261390767 [16] -0.262745230 -0.306223863 -0.070407061 -0.143807390 -0.160524470 [21] -0.028979388 -0.024826317 0.087507825 -0.004416206 0.100828133 [26] 0.032866561 0.059402858 0.034034014 0.036832394 0.027864299 [31] 0.049129749 -0.029343892 -0.068129000 0.071835347 -0.059058051 [36] 0.004732397 0.078459372 0.050783649 0.005004941 0.040969637 [41] 0.084883263 -0.011384237 0.073865617 0.108005496 0.136470769 [46] -0.037177301 0.041317210 0.048613150 -0.054056077 > (mypacf <- c(rpacf$acf)) [1] 0.342643706 0.253447184 0.248898853 0.149419350 -0.345928385 [6] -0.082410006 0.211595034 -0.138352195 -0.212775728 -0.350983585 [11] -0.022098076 -0.384406058 0.245519523 0.058800539 0.050995131 [16] 0.004187351 -0.054116399 -0.020219264 0.143286911 -0.059747062 [21] -0.263047824 -0.067943969 -0.065321339 -0.344836460 0.095695684 [26] -0.096154683 0.092772678 -0.055540661 0.066780547 -0.023455057 [31] -0.020989108 -0.090084230 0.024292489 -0.030512439 0.019037811 [36] -0.162902617 -0.097293022 -0.071613134 0.058862096 -0.098149980 [41] -0.027978199 0.044170516 0.039481116 0.014230087 -0.033402069 [46] -0.196437585 0.074214024 0.006630461 > 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/4m2nz1413725950.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/5wqgb1413725950.tab") > > try(system("convert tmp/1op851413725950.ps tmp/1op851413725950.png",intern=TRUE)) character(0) > try(system("convert tmp/2g8xh1413725950.ps tmp/2g8xh1413725950.png",intern=TRUE)) character(0) > try(system("convert tmp/3uh9r1413725950.ps tmp/3uh9r1413725950.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.155 0.198 1.368