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(98.91,98.15,98.59,98.6,98.7,98.33,98.33,98.6,98.52,99.17,99.49,98.83,98.83,97.39,99.28,98.78,98.75,98.47,98.47,97.82,97.79,97.96,98.21,98.34,98.34,98.49,98.14,98.05,97.77,97.59,97.59,97.67,97.67,97.36,97.31,97.24,97.24,96.89,96.48,96.47,97.13,97.21,97.43,97.98,97.97,98.2,98.67,98.75,98.77,98.72,99.23,99.67,99.76,99.57,99.57,100.21,100.62,101.05,101.42,101.42,101.52,101.87,101.53,101.77,101.76,102.04,102.05,101.9,102.17,102.14,102.09,102.27) > 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/14bha1445605642.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/2pufn1445605642.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/3mbdp1445605642.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.0000000000 -0.2547994888 0.1565758756 -0.1450905054 0.0832920146 [6] 0.0688054161 0.0360635444 0.1150395027 0.0679377644 -0.0795739832 [11] 0.0808226420 0.0241122887 0.0882046511 -0.1045246003 0.0281610040 [16] 0.0838042108 0.0478020734 -0.0537518595 0.0752920176 -0.0788230546 [21] 0.0096277305 -0.0208652964 -0.0088555681 -0.0762224664 -0.1118263009 [26] 0.0555633545 0.0674152691 -0.1112769272 -0.0275642032 -0.0167716423 [31] -0.1008766827 -0.0251748870 0.0116833108 0.0008980318 0.0286333038 [36] -0.0953395924 0.0945612412 0.0085842245 -0.0569476776 -0.1406977550 [41] -0.0401061521 0.0917198387 -0.0640957346 0.0355991568 -0.0528903949 [46] -0.1012560558 -0.0173006051 0.0597401337 -0.0378494962 > (mypacf <- c(rpacf$acf)) [1] -0.254799489 0.098016607 -0.090844899 0.017435142 0.126484831 [6] 0.061118025 0.138330112 0.152394988 -0.063849826 0.045998808 [11] 0.075442343 0.042058767 -0.107959178 -0.047916981 0.085948942 [16] 0.060406453 -0.072117829 0.050494027 -0.048984595 -0.060456751 [21] 0.004214453 -0.089653464 -0.160749840 -0.144938161 0.017925252 [26] 0.084200503 -0.101676130 -0.040868278 0.096672200 -0.112373924 [31] -0.058028034 0.063111108 -0.044587145 0.089578682 0.059595660 [36] 0.069393492 0.120006203 0.022151299 -0.128594694 -0.135712588 [41] 0.022138602 -0.034202776 -0.060983083 -0.078188979 -0.087744368 [46] -0.040264506 0.081439960 -0.072256068 > 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/4atuc1445605642.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/58qlb1445605642.tab") > > try(system("convert tmp/14bha1445605642.ps tmp/14bha1445605642.png",intern=TRUE)) character(0) > try(system("convert tmp/2pufn1445605642.ps tmp/2pufn1445605642.png",intern=TRUE)) character(0) > try(system("convert tmp/3mbdp1445605642.ps tmp/3mbdp1445605642.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.156 0.202 1.370