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(99.42,99.42,99.42,99.42,99.42,109.26,110.00,110.00,109.26,100.07,100.07,100.05,100.05,100.05,100.05,100.05,100.05,108.77,111.32,111.60,108.52,103.13,102.87,102.75,102.75,102.75,102.75,102.75,102.75,115.22,115.53,115.40,111.99,107.93,107.43,106.98,106.98,106.98,106.98,106.98,106.98,113.71,118.77,118.54,116.16,110.52,110.06,109.90,109.90,110.72,110.09,110.07,112.45,113.06,119.83,119.84,113.73,110.50,110.12,109.86,110.36,110.36,110.59,112.52,112.10,115.90,122.96,121.26,114.55,111.57,110.65,109.77) > 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/1b8ps1358281226.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/257f51358281226.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/3qr4a1358281226.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.238497241 -0.092512126 -0.231277233 -0.338576104 [6] -0.047418036 -0.027143760 -0.048383699 -0.248615700 -0.230104459 [11] -0.063669260 0.263214843 0.690564897 0.255650466 -0.067449343 [16] -0.233056025 -0.264042141 -0.036384597 -0.023135916 -0.027944463 [21] -0.220346955 -0.160331970 -0.029561779 0.226685814 0.497842813 [26] 0.270479871 -0.055008055 -0.255218507 -0.201063391 -0.033368717 [31] -0.029016619 -0.018357017 -0.104009575 -0.156477687 -0.004949655 [36] 0.138856729 0.324969655 0.278624845 -0.040489741 -0.211532587 [41] -0.162647677 -0.021778930 -0.030063591 -0.025632282 -0.022409732 [46] -0.134040235 0.003595676 0.158438334 0.161627392 > (mypacf <- c(rpacf$acf)) [1] 0.2384972412 -0.1584031808 -0.1826513364 -0.2788036681 0.0526252346 [6] -0.1538467826 -0.1495941830 -0.4159483555 -0.2911949579 -0.3761005794 [11] -0.1119842964 0.3996453427 0.0037086139 -0.0513745509 -0.0595507751 [16] 0.0698668853 0.0242117296 -0.0358070774 0.0094672073 -0.0678812220 [21] 0.1052865051 -0.0027845000 0.0004964383 -0.0468456583 0.1475954031 [26] 0.0004627526 -0.0558030715 0.0090514944 0.0579259947 -0.0355167055 [31] -0.0007922185 0.1674923321 -0.0524035573 0.0559763595 -0.1065917555 [36] -0.0527724839 0.0208145336 -0.0015216368 -0.0218291837 -0.0723277717 [41] 0.0992351000 -0.0742030943 -0.0463912678 0.0099408880 -0.0033057763 [46] -0.0021465411 0.1541074728 -0.1045916862 > 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/4kd0o1358281226.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/574xw1358281226.tab") > > try(system("convert tmp/1b8ps1358281226.ps tmp/1b8ps1358281226.png",intern=TRUE)) character(0) > try(system("convert tmp/257f51358281226.ps tmp/257f51358281226.png",intern=TRUE)) character(0) > try(system("convert tmp/3qr4a1358281226.ps tmp/3qr4a1358281226.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.309 0.402 2.678