R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(143.7,149.3,121.7,81,68.1,92.3,107.7,114.4,98.6,106.7,73.9,85.9,118.4,144.2,118.4,82.6,68,99.8,93.4,107.9,101.1,100.4,76.7,89.1,105.3,124.8,111.9,89,88.6,84.5,91.1,118.1,103.6,92.6,70.2,70.2,114.3,125.3,98.9,65.4,66,71.2,84.6,102.6,91.8,97.4,64.1,62.3,96.2,104.9,90.3,65.2,57.8,70.5,93.2,74.2,91.1,85,58.9,68.3,98.1,110.5,77.6,55.1,49.8,58.5,86.5,88.8,94,65,52.2,70.9) > 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/1itt71445596786.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/2u5z31445596786.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/3xe7y1445596786.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.54648329 -0.05750800 -0.29268031 -0.02072570 0.37751037 [7] 0.55798860 0.39835451 0.02667301 -0.26359982 -0.13188040 0.36915082 [13] 0.65092242 0.35795961 -0.06638847 -0.26524060 -0.07420882 0.23916158 [19] 0.36833216 0.24873495 -0.06879603 -0.29776421 -0.16336757 0.24415868 [25] 0.42249261 0.20529922 -0.16179456 -0.32538488 -0.15914929 0.09273685 [31] 0.24039819 0.15929728 -0.14691607 -0.35459711 -0.25165355 0.08519976 [37] 0.25513930 0.06105547 -0.24627490 -0.34310163 -0.21317343 -0.04580033 [43] 0.05725341 0.02971472 -0.14987320 -0.28088547 -0.23801890 0.01291240 [49] 0.12481203 > (mypacf <- c(rpacf$acf)) [1] 0.5464832855 -0.5078048419 0.0618877127 0.3156795310 0.2108457289 [6] 0.2600818696 0.1545383752 -0.0830647877 -0.1821975079 0.1251605433 [11] 0.3696125309 0.0621716819 -0.2203943194 0.1873862107 -0.1069860929 [16] -0.0552534997 0.0052466210 -0.1666954232 -0.0356607899 -0.0711652940 [21] -0.0162890291 -0.0035047135 0.0723428203 -0.0166973528 -0.0281631561 [26] -0.0546259439 -0.0352017910 -0.0672359104 -0.0795655951 0.0618931836 [31] -0.0189984260 -0.0900141024 0.0460124744 -0.0855978091 -0.0017810755 [36] -0.0008957883 -0.1898182865 0.0390025782 0.0547829471 -0.1018539568 [41] -0.1060077071 -0.0636328713 0.1359216074 -0.0029983790 0.0766573363 [46] 0.0001173271 0.0280739094 0.0125184568 > 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/44hg61445596786.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/5jwhb1445596786.tab") > > try(system("convert tmp/1itt71445596786.ps tmp/1itt71445596786.png",intern=TRUE)) character(0) > try(system("convert tmp/2u5z31445596786.ps tmp/2u5z31445596786.png",intern=TRUE)) character(0) > try(system("convert tmp/3xe7y1445596786.ps tmp/3xe7y1445596786.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.105 0.225 1.340