R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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.71,2.69,2.67,2.66,2.67,2.67,2.66,2.72,2.63,2.63,2.65,2.66,2.65,2.62,2.61,2.61,2.62,2.61,2.62,2.65,2.64,2.66,2.67,2.68,2.68,2.71,2.72,2.72,2.71,2.7,2.7,2.7,2.68,2.67,2.66,2.64,2.64,2.63,2.61,2.62,2.61,2.6,2.58,2.55,2.53,2.5,2.48,2.47,2.47,2.46,2.46,2.45,2.44,2.42,2.39,2.37,2.34,2.32,2.3,2.29,2.3,2.29,2.29,2.29,2.29,2.28,2.28,2.28,2.29) > 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/1aird1338223635.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/20j3h1338223635.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/3zise1338223635.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.96068755 0.92049029 0.87889609 0.83414954 0.78713546 [7] 0.73652236 0.68498176 0.62441373 0.57337386 0.51754573 0.46024669 [13] 0.40311267 0.34618633 0.29783222 0.25171435 0.20909876 0.16769518 [19] 0.13093762 0.09407194 0.05396856 0.01582829 -0.02523388 -0.06489911 [25] -0.10197817 -0.13418076 -0.16567208 -0.19306080 -0.21761297 -0.23810806 [31] -0.25690179 -0.27812807 -0.29422751 -0.30732823 -0.31867354 -0.32549233 [37] -0.32833086 -0.32867140 -0.32513979 -0.31914434 -0.31418450 -0.30641088 [43] -0.29798289 -0.28813805 -0.27860047 -0.27324232 -0.26615152 -0.25955291 [49] -0.25343512 > (mypacf <- c(rpacf$acf)) [1] 0.960687554 -0.031529662 -0.038948114 -0.062765291 -0.053002776 [6] -0.071809198 -0.038778192 -0.146517980 0.093960879 -0.094939752 [11] -0.046264960 -0.039590709 -0.029724913 0.069204246 0.006657693 [16] -0.017902417 0.003155238 0.007069712 -0.049597287 -0.087532405 [21] -0.043706493 -0.067411546 -0.037769239 -0.016274184 0.016557722 [26] -0.020626382 0.028616148 -0.013936740 0.036362813 -0.025425248 [31] -0.065593451 0.017911256 -0.005142160 -0.036834258 0.017030993 [36] -0.001789124 0.004841193 0.033735002 -0.017964610 -0.018683821 [41] 0.026376609 -0.017214150 0.002083755 -0.037796960 -0.084162451 [46] 0.003196513 -0.031996946 -0.039850035 > 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/41vcm1338223635.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/54fkv1338223635.tab") > > try(system("convert tmp/1aird1338223635.ps tmp/1aird1338223635.png",intern=TRUE)) character(0) > try(system("convert tmp/20j3h1338223635.ps tmp/20j3h1338223635.png",intern=TRUE)) character(0) > try(system("convert tmp/3zise1338223635.ps tmp/3zise1338223635.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.976 0.199 1.173