R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(3.65,3.66,3.69,3.7,3.7,3.71,3.71,3.71,3.72,3.72,3.73,3.74,3.78,3.78,3.79,3.79,3.8,3.81,3.83,3.84,3.88,3.91,3.96,3.96,3.97,3.98,3.99,3.99,4,4,4.02,4.02,4.02,4.03,4.03,4.03,4.04,4.04,4.05,4.05,4.05,4.05,4.06,4.06,4.06,4.06,4.07,4.07,4.08,4.08,4.08,4.09,4.09,4.09,4.09,4.1,4.1,4.11,4.11,4.12,4.12,4.12,4.12,4.12,4.15,4.15,4.15,4.15,4.16,4.16,4.16,4.2) > 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/112cd1353682943.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/2hsk41353682943.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/3lh781353682943.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.0000000000 0.9523121629 0.9087558438 0.8673672242 0.8255575631 [6] 0.7821441950 0.7387597296 0.6929568146 0.6449041790 0.5994934028 [11] 0.5515516909 0.5021765634 0.4530553106 0.4092802687 0.3652513520 [16] 0.3213075811 0.2775036365 0.2333348935 0.1908534409 0.1497796259 [21] 0.1090721717 0.0735984423 0.0437505766 0.0219212462 -0.0007517295 [26] -0.0213437137 -0.0410631501 -0.0590390530 -0.0776898720 -0.0955806293 [31] -0.1144275177 -0.1291397635 -0.1447518976 -0.1607577327 -0.1757785339 [36] -0.1906595088 -0.2066091009 -0.2203089725 -0.2348524892 -0.2484672151 [41] -0.2616608996 -0.2754732572 -0.2901292600 -0.3013833416 -0.3139310126 [46] -0.3261701281 -0.3392528888 -0.3503671441 -0.3611728439 > (mypacf <- c(rpacf$acf)) [1] 0.9523121629 0.0199501334 0.0023043776 -0.0246909868 -0.0398884904 [6] -0.0256356557 -0.0518321645 -0.0535466339 -0.0038565131 -0.0546108585 [11] -0.0466253748 -0.0321797927 0.0236008651 -0.0267690797 -0.0286993542 [16] -0.0315823220 -0.0369814016 -0.0183177658 -0.0220728027 -0.0317736126 [21] 0.0243112484 0.0294094001 0.0636754694 -0.0244533785 -0.0005074381 [26] -0.0166462872 -0.0110236303 -0.0388224097 -0.0259457773 -0.0415348007 [31] 0.0149225911 -0.0410622635 -0.0277776872 -0.0139355782 -0.0178460307 [36] -0.0418691357 -0.0067119603 -0.0393708676 -0.0136901843 -0.0259575302 [41] -0.0337558712 -0.0348177716 0.0212747260 -0.0344873674 -0.0159998375 [46] -0.0406374669 -0.0064774186 -0.0269558590 > 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/4swux1353682943.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/5w3ih1353682943.tab") > > try(system("convert tmp/112cd1353682943.ps tmp/112cd1353682943.png",intern=TRUE)) character(0) > try(system("convert tmp/2hsk41353682943.ps tmp/2hsk41353682943.png",intern=TRUE)) character(0) > try(system("convert tmp/3lh781353682943.ps tmp/3lh781353682943.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.074 0.378 2.419