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(164,96,73,49,39,59,169,169,210,278,298,245,200,188,90,79,78,91,167,169,289,247,275,203,223,104,107,85,75,99,135,211,335,488,326,346,261,224,141,148,145,223,272,445,560,612,467,404,518,404,300,210,196,186,247,343,464,680,711,610,513,292,273,322,189,257,324,404,677,858,895,664,628,308,324,248,272) > 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/fisher/rcomp/tmp/18qjn1355752663.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/fisher/rcomp/tmp/2bb1p1355752663.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/fisher/rcomp/tmp/38jz81355752663.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.277631372 0.229729107 -0.131974138 -0.248477022 [6] -0.412364846 -0.331554549 -0.336216111 -0.248678529 0.045809866 [11] 0.111424606 0.339382916 0.434239817 0.323028855 0.119397219 [16] 0.073812141 -0.268925123 -0.265656543 -0.316890536 -0.269873173 [21] -0.096580910 -0.008651852 0.100879929 0.125210781 0.334355816 [26] 0.260121173 0.187186640 0.080974925 -0.143177264 -0.233385559 [31] -0.219100985 -0.203045728 -0.178177732 0.019054990 0.002718336 [36] 0.200697415 0.192958587 0.248179133 0.047381561 0.101016150 [41] -0.162632144 -0.154768881 -0.146908291 -0.141575298 -0.101156370 [46] -0.011124336 0.051140870 0.058016824 0.189037609 > (mypacf <- c(rpacf$acf)) [1] 2.776314e-01 1.653987e-01 -2.574712e-01 -2.296651e-01 -2.694603e-01 [6] -1.550654e-01 -2.375490e-01 -3.256706e-01 -4.596775e-02 -1.612005e-01 [11] -2.573771e-02 1.565940e-01 4.113169e-03 -7.332565e-02 1.440370e-01 [16] -1.277299e-01 -2.248736e-05 4.709500e-03 -5.249376e-02 1.365080e-01 [21] -9.477496e-02 -7.354354e-02 -1.176641e-01 4.502102e-03 1.367192e-01 [26] -6.616389e-02 4.499797e-02 1.196480e-02 -7.057049e-02 9.020255e-02 [31] 3.629060e-02 -1.196862e-01 1.356757e-01 -7.518086e-02 1.047921e-01 [36] 1.561740e-02 -4.937873e-02 -2.324705e-02 -2.931454e-02 -1.369778e-01 [41] 2.398711e-02 -3.316844e-02 8.800846e-02 -4.651753e-02 -1.228269e-01 [46] 4.003495e-02 -1.235816e-01 6.242079e-03 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/48omy1355752663.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/fisher/rcomp/tmp/558nw1355752663.tab") > > try(system("convert tmp/18qjn1355752663.ps tmp/18qjn1355752663.png",intern=TRUE)) character(0) > try(system("convert tmp/2bb1p1355752663.ps tmp/2bb1p1355752663.png",intern=TRUE)) character(0) > try(system("convert tmp/38jz81355752663.ps tmp/38jz81355752663.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.777 0.558 2.320