R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" 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(500,500.01,500.02,500.03,500.04,500.05,500.06,500.07,500.08,500.09,500.10,500.11,500.12,500.13,500.14,500.15,500.16,500.17,500.18,500.19,500.20,500.21,500.22,500.23,500.24,500.25,500.26,500.27,500.28,500.29,500.30,500.31,500.32,500.33,500.34,500.35,500.36,500.37,500.38,500.39,500.40,500.41,500.42,500.43,500.44,500.45,500.46,500.47,500.48,500.49,500.50,500.51,500.52,500.53,500.54,500.55,500.56,500.57,500.58,500.59,500.60,500.61,500.62,500.63,500.64,500.65,500.66,500.67,500.68,500.69,500.70,500.71) > 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/1frij1387650188.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/2dyv81387650188.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/37f4z1387650188.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.95833333 0.91669882 0.87512863 0.83365490 0.79230979 [7] 0.75112547 0.71013409 0.66936781 0.62885877 0.58863914 0.54874108 [13] 0.50919673 0.47003827 0.43129783 0.39300759 0.35519969 0.31790630 [19] 0.28115956 0.24499164 0.20943469 0.17452087 0.14028233 0.10675124 [25] 0.07395974 0.04194000 0.01072416 -0.01965560 -0.04916715 -0.07777831 [31] -0.10545694 -0.13217088 -0.15788797 -0.18257605 -0.20620297 -0.22873657 [37] -0.25014470 -0.27039520 -0.28945591 -0.30729468 -0.32387935 -0.33917776 [43] -0.35315776 -0.36578719 -0.37703389 -0.38686571 -0.39525050 -0.40215609 [49] -0.40755032 > (mypacf <- c(rpacf$acf)) [1] 0.95833333 -0.02088251 -0.02093333 -0.02098540 -0.02103833 -0.02109171 [7] -0.02114507 -0.02119796 -0.02124988 -0.02130030 -0.02134866 -0.02139436 [13] -0.02143678 -0.02147522 -0.02150896 -0.02153723 -0.02155918 -0.02157394 [19] -0.02158054 -0.02157796 -0.02156510 -0.02154078 -0.02150374 -0.02145262 [25] -0.02138597 -0.02130224 -0.02119977 -0.02107678 -0.02093136 -0.02076150 [31] -0.02056503 -0.02033967 -0.02008296 -0.01979233 -0.01946504 -0.01909820 [37] -0.01868877 -0.01823356 -0.01772923 -0.01717229 -0.01655911 -0.01588594 [43] -0.01514891 -0.01434405 -0.01346730 -0.01251453 -0.01148158 -0.01036424 > 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/4gmx31387650188.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/5ywp41387650188.tab") > > try(system("convert tmp/1frij1387650188.ps tmp/1frij1387650188.png",intern=TRUE)) character(0) > try(system("convert tmp/2dyv81387650188.ps tmp/2dyv81387650188.png",intern=TRUE)) character(0) > try(system("convert tmp/37f4z1387650188.ps tmp/37f4z1387650188.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.569 0.541 3.085