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(0.67,0.66,0.66,0.67,0.67,0.67,0.67,0.68,0.68,0.67,0.67,0.67,0.67,0.67,0.69,0.69,0.69,0.69,0.69,0.69,0.7,0.69,0.68,0.7,0.7,0.71,0.69,0.7,0.7,0.71,0.71,0.71,0.71,0.7,0.7,0.71,0.71,0.71,0.71,0.7,0.69,0.7,0.7,0.7,0.71,0.7,0.7,0.69,0.7,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.71,0.69,0.7,0.7,0.7,0.72,0.7,0.69,0.7,0.71,0.72,0.72,0.73,0.72,0.74,0.75) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '0.0' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > par2 <- '0.0' > 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/1yjj11353091813.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/2fj4l1353091813.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/356w11353091813.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.216417712 -0.109426484 -0.086641137 -0.061989338 [6] 0.090204140 0.095443219 0.119340827 -0.215062673 0.012383807 [11] 0.021497747 -0.039934796 0.131550049 -0.079566777 -0.111577997 [16] 0.009437556 -0.059739681 0.192037200 -0.026030541 -0.123161839 [21] 0.033121130 0.085291591 -0.070385274 -0.005778278 0.104319855 [26] -0.053421691 -0.029498101 -0.044284995 -0.131402852 0.120855629 [31] 0.031107001 0.017713310 -0.076820738 -0.083678304 -0.045194308 [36] 0.012437519 0.150531522 -0.059340857 0.069529818 -0.102317036 [41] -0.141588641 0.224559736 -0.047253288 -0.035056699 -0.058279317 [46] 0.047464895 0.007251137 0.112812083 -0.031471512 > (mypacf <- c(rpacf$acf)) [1] -0.216417712 -0.163941581 -0.161377840 -0.158756655 -0.006849289 [6] 0.080792337 0.187583875 -0.101838619 0.007782227 0.019652948 [11] -0.070415498 0.059626165 -0.054779044 -0.129634679 -0.022383135 [16] -0.148701138 0.124581618 0.030238715 -0.128050886 0.090276567 [21] 0.144999362 -0.089189900 -0.011577214 0.046241222 0.046632315 [26] -0.007648187 -0.181816882 -0.199210622 0.034502629 -0.078587281 [31] 0.047005408 -0.022864679 -0.106092191 -0.046909510 -0.060275657 [36] 0.063189366 0.013091737 0.037338336 0.040280110 -0.124465793 [41] 0.023369527 -0.109153233 -0.110851659 -0.070430941 0.036326225 [46] -0.026809337 0.139512228 -0.050493827 > 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/4q7g11353091813.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/54pj51353091813.tab") > > try(system("convert tmp/1yjj11353091813.ps tmp/1yjj11353091813.png",intern=TRUE)) character(0) > try(system("convert tmp/2fj4l1353091813.ps tmp/2fj4l1353091813.png",intern=TRUE)) character(0) > try(system("convert tmp/356w11353091813.ps tmp/356w11353091813.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 6.043 1.306 7.361