R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 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(13.29,13.34,13.41,13.45,13.52,13.52,13.53,13.55,13.52,13.51,13.55,13.56,13.62,13.69,13.67,13.66,13.69,13.69,13.7,13.73,13.79,13.8,13.84,13.84,13.88,13.97,14.06,14.11,14.13,14.15,14.2,14.28,14.3,14.33,14.4,14.4,14.42,14.51,14.64,14.68,14.72,14.73,14.76,14.78,14.83,14.84,14.85,14.87,14.87,14.96,15.08,15.08,15.12,15.12,15.1,15.16,15.22,15.28,15.29,15.32,15.4,15.44,15.48,15.52,15.6,15.61,15.66,15.69,15.75,15.82,15.81,15.82) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/11kli1369610930.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/2b6b41369610930.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/34m4x1369610930.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.960464100 0.920214161 0.879787498 0.840760034 [6] 0.803881930 0.766042993 0.727856197 0.688495071 0.648960308 [11] 0.608605374 0.568977864 0.528936841 0.490788379 0.453614622 [16] 0.414577184 0.375795832 0.338357543 0.301385685 0.262086055 [21] 0.221754446 0.183043426 0.143289059 0.106878394 0.071870240 [26] 0.036180794 0.001902955 -0.031073371 -0.063678449 -0.095352126 [31] -0.127081938 -0.158056584 -0.187860538 -0.216927387 -0.244960245 [36] -0.268094303 -0.289528799 -0.310965634 -0.331208711 -0.346667209 [41] -0.360928311 -0.374293908 -0.385347455 -0.394665153 -0.403568852 [46] -0.411116429 -0.417383934 -0.421149769 -0.422131081 -0.422538692 [51] -0.420910513 -0.415003298 -0.409149718 -0.400566222 -0.391453629 [56] -0.382969735 -0.373162952 -0.361216489 -0.348263063 -0.335983750 [61] -0.321004604 > (mypacf <- c(rpacf$acf)) [1] 0.960464100 -0.029378971 -0.023163380 -0.003390108 0.006249449 [6] -0.033483860 -0.025568581 -0.036218267 -0.024945863 -0.035280334 [11] -0.015998230 -0.031480453 -0.001662551 -0.013490886 -0.049444416 [16] -0.023504216 -0.008484241 -0.023128222 -0.060443751 -0.043698699 [21] -0.010227439 -0.047864891 0.007016484 -0.014708626 -0.041578459 [26] -0.014408301 -0.014915802 -0.030816240 -0.022430036 -0.035840496 [31] -0.028570411 -0.025315742 -0.025776779 -0.025682305 0.024652133 [36] -0.011959495 -0.036214165 -0.018542258 0.032362704 -0.018352856 [41] -0.024823223 -0.003634065 -0.004255843 -0.028416442 -0.013079381 [46] -0.012633090 0.003390451 0.008922717 -0.019454467 -0.001183384 [51] 0.039055423 -0.020351348 0.007291815 -0.011399665 -0.020745070 [56] -0.005139907 0.010397634 -0.002988319 -0.024564364 0.020861791 > 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/48i9p1369610930.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/5ev361369610930.tab") > > try(system("convert tmp/11kli1369610930.ps tmp/11kli1369610930.png",intern=TRUE)) character(0) > try(system("convert tmp/2b6b41369610930.ps tmp/2b6b41369610930.png",intern=TRUE)) character(0) > try(system("convert tmp/34m4x1369610930.ps tmp/34m4x1369610930.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.297 0.492 2.765