R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 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(122.27,124.69,147.56,120.03,136.01,138.16,122.87,112.22,137.35,139.08,139.64,121.12,132.37,130.69,149.41,130.72,139.14,146.55,137.35,122.73,138.97,154.73,143.4,123.88,140.25,142.39,143.81,153.58,144.71,153.84,151.3,121.92,153.05,149.29,118.81,109.19,103.68,106.94,114.43,107.87,103.14,117.02,112.44,95.85,123.86,121.83,121.95,120.34,113.32,117.31,141.69,130.35,127.28,148.1,131.21,120.37,146.91,144.04,141.77,132.15,142.04,149.77,172.31,150.24,163.23,155.92,146.96,134.51,152.83,150.54,150.98,138.82) > 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/19zxu1363703225.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/2aa6b1363703225.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/38vmm1363703225.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.59546741 0.45085071 0.52269471 0.48994576 0.36361902 [7] 0.36221337 0.20008637 0.20919059 0.04933717 -0.12773132 -0.03851990 [13] 0.11240706 -0.17516314 -0.30000726 -0.24816383 -0.24352087 -0.28244096 [19] -0.28718046 -0.34767740 -0.29595758 -0.40836728 -0.46715139 -0.32265528 [25] -0.20983116 -0.32131319 -0.38194424 -0.30737490 -0.17172065 -0.13359292 [31] -0.07495198 -0.04240293 0.04831462 0.03167757 0.02281477 0.12538803 [37] 0.25341978 0.16732376 0.09545690 0.12009711 0.17056704 0.12878058 [43] 0.13649817 0.09992613 0.10174885 0.05590180 0.02253928 0.04123807 [49] 0.14187853 > (mypacf <- c(rpacf$acf)) [1] 0.5954674126 0.1491578916 0.3255686461 0.1130149736 -0.0470578649 [6] 0.0593833135 -0.2713086504 0.0896666121 -0.3389441578 -0.2453496681 [11] 0.1611251320 0.3090505493 -0.2092165788 -0.2572964531 -0.0689427264 [16] 0.0074312494 0.0415459956 -0.0593471119 -0.1079929124 -0.0687465214 [21] -0.1195839202 0.0338057842 -0.0309696409 -0.0492570410 0.0490686919 [26] -0.1122879500 -0.0072594475 0.1053043456 0.0558399292 0.1180961057 [31] -0.1034872746 0.0380876385 0.0332129337 -0.0806010626 -0.1198862938 [36] -0.0509713409 -0.0170626866 0.0180539237 0.0008504963 -0.1364772591 [41] -0.1381297827 0.0411710405 0.0252303018 0.0016664889 -0.0741371789 [46] 0.0653380802 -0.0136821420 0.0194954686 > 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/4r44g1363703225.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/5jygh1363703225.tab") > > try(system("convert tmp/19zxu1363703225.ps tmp/19zxu1363703225.png",intern=TRUE)) character(0) > try(system("convert tmp/2aa6b1363703225.ps tmp/2aa6b1363703225.png",intern=TRUE)) character(0) > try(system("convert tmp/38vmm1363703225.ps tmp/38vmm1363703225.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.786 0.292 2.058