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(1.974,2.037,2.259,2.550,2.549,2.738,2.228,2.533,2.475,2.260,2.158,2.253,2.670,2.449,2.620,2.205,2.589,2.706,2.352,2.478,2.316,2.295,2.110,1.944,2.202,2.036,2.434,2.297,2.354,2.650,2.555,2.477,2.268,2.510,2.015,1.994,2.271,2.289,2.333,2.795,2.332,2.799,2.294,2.415,2.473,2.236,1.970,2.318,2.108,2.064,2.519,2.298,2.187,2.746,2.364,2.512,2.224,2.209,2.186,2.303,2.381,2.432,2.913,2.392,2.532,2.709,2.387,2.609,2.399,2.184,1.839,2.056,2.151,2.155,2.463,2.155,2.679,2.367,2.052,2.547,2.466) > 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/1hppg1338139157.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/2no161338139157.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/3b6bs1338139157.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.4929363748 0.0883925234 0.1322921202 -0.1993957357 [6] 0.0625910051 -0.1094009585 -0.0065896234 -0.1178422763 0.1860566112 [11] -0.0806932250 -0.1252274393 0.4045731934 -0.3492777224 0.2908686319 [16] 0.0007073497 -0.2432256114 0.1483435580 -0.1167575768 -0.0136634519 [21] -0.1285012374 0.1705195301 -0.0851170368 0.0388891272 0.1482789634 [26] -0.1158106191 0.1431770588 -0.0151032496 -0.1259143832 0.1390300103 [31] -0.1683207339 -0.0080051931 -0.0120603532 0.0227934742 -0.0067260876 [36] -0.0100984217 0.1887806622 -0.1257963341 0.1066349381 -0.0692342114 [41] -0.0461800080 0.0476827764 -0.1283450379 0.1340475796 -0.1558195809 [46] 0.0499984065 0.0612921735 -0.0933950123 0.1861006289 > (mypacf <- c(rpacf$acf)) [1] -0.4929363748 -0.2042152474 0.1159248797 -0.0766900634 -0.1042578642 [6] -0.2107829034 -0.1626655147 -0.3011741709 -0.0047753684 0.0009619919 [11] -0.2725351170 0.1621199645 -0.0890161775 0.1464644071 0.1958474849 [16] -0.0895246624 -0.1150557035 -0.0832697809 -0.0265545514 -0.1712381816 [21] -0.0635510388 -0.0230317208 -0.0432877493 -0.0713262392 0.1421348008 [26] -0.0220479476 0.0248340286 -0.0218337290 0.0779665555 0.0165648995 [31] -0.0419049738 0.0013791069 -0.0492576267 0.0635887456 -0.0789434814 [36] 0.0970812251 0.0265944784 0.0194415087 -0.1463535658 -0.0493661778 [41] -0.0489402505 -0.0494301992 0.1817949312 -0.0475546326 -0.0476824715 [46] -0.0286475725 -0.0308133426 0.0071208801 > 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/4lexz1338139157.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/5azoh1338139157.tab") > > try(system("convert tmp/1hppg1338139157.ps tmp/1hppg1338139157.png",intern=TRUE)) character(0) > try(system("convert tmp/2no161338139157.ps tmp/2no161338139157.png",intern=TRUE)) character(0) > try(system("convert tmp/3b6bs1338139157.ps tmp/3b6bs1338139157.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.021 0.219 1.233