R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 The R Foundation for Statistical Computing 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.7,107.5,107.5,114.5,118.7,117.8,111.7,112.3,104.9,102.4,100.3,106.6,94.2,96.9,94.7,104.9,108.3,104.7,108.3,105.2,99.2,99.3,92.3,98.6,88.4,89.5,90.5,103.5,105.1,107.1,111.6,104.6,103.3,104.6,94.1,97.7,92.4,89.5,100.1,109.6,105.5,108.9,108.8,103.9,104.3,102.1,96.6,101.4,90.4,91.8,100.4,105.3,105.1,107.6,103.7,102.7,99.2,95.6,96.3,104.1) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1rnc91394996633.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/2tf0e1394996633.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/36n0x1394996633.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.673768774 0.444401660 0.154043113 -0.125865404 [6] -0.307421791 -0.340169437 -0.358268025 -0.174882018 -0.017904851 [11] 0.167849863 0.345203395 0.523108846 0.293523324 0.183678170 [16] -0.065600151 -0.260050235 -0.366957873 -0.440270613 -0.418459909 [21] -0.241322240 -0.141225511 0.069448752 0.213721014 0.300502500 [26] 0.197505034 0.138395629 -0.014684099 -0.082803058 -0.169605721 [31] -0.228700203 -0.184270752 -0.106687961 -0.073556143 0.078910694 [36] 0.146872318 0.201222205 0.146800934 0.080270291 -0.007931779 [41] -0.032233821 -0.102193167 -0.121382522 -0.109950008 -0.094846554 [46] -0.087034544 -0.022239371 -0.001942137 0.055937790 0.044803613 [51] 0.006932868 -0.036685774 -0.054894144 -0.078500474 -0.058462136 [56] -0.032912933 -0.012422394 -0.001571993 0.008642850 -0.001633890 > (mypacf <- c(rpacf$acf)) [1] 0.6737687740 -0.0175129607 -0.2543195783 -0.2529250995 -0.1112877362 [6] 0.0646746660 -0.1028577647 0.1886998183 0.0461455917 0.1019388962 [11] 0.1579044263 0.2937594908 -0.5158413314 0.0355894790 -0.0843306765 [16] 0.0278234937 -0.0517964755 -0.1931341877 0.0642278788 -0.0492274430 [21] -0.0147738040 0.0702005176 -0.0916429657 -0.0912263497 0.0814845855 [26] 0.0027691057 0.1432676923 0.0196135144 -0.0833516669 0.0634923546 [31] 0.0107012214 -0.0443812493 -0.0668258239 -0.0667893621 0.0763521546 [36] -0.0144277306 -0.0661205185 -0.0188614455 -0.0724834417 0.0642882673 [41] 0.0678168681 -0.0595126340 -0.0950221455 -0.0115601048 0.0098919025 [46] 0.0001717109 -0.0468163803 -0.0031270452 0.0563058349 -0.1062755596 [51] -0.0518362156 -0.0284202441 0.0443373345 0.0276275088 0.0575257329 [56] -0.0450148996 -0.0118665324 -0.0532941246 -0.0157642953 > 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/48cyy1394996633.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/5pud51394996633.tab") > > try(system("convert tmp/1rnc91394996633.ps tmp/1rnc91394996633.png",intern=TRUE)) character(0) > try(system("convert tmp/2tf0e1394996633.ps tmp/2tf0e1394996633.png",intern=TRUE)) character(0) > try(system("convert tmp/36n0x1394996633.ps tmp/36n0x1394996633.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.122 0.666 3.824