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(93.58,95.79,94.77,94.2,96.23,92.3,88.86,86.44,86.21,88.57,90.69,89,86.88,90.65,90.68,89.64,102.62,101.84,92.51,94.29,94.68,96.94,94.03,89.65,84.9,89.07,89.8,93.22,92.23,98.41,96.63,89.8,90,92.13,93.27,90.81,85.42,88.28,88.73,90.18,92.74,96.13,94.85,94.25,96.94,101.22,98.71,95.51,93.91,98.17,97.59,99.64,107.88,108.49,100.25,99.27,101.73,101.25,97.09,94.74,94.53,93.48,96.05,106.22,98.33,99.86,93.78,88.96,83.77,89.46,86.78,88.4) > 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/1a90u1445588327.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/290vo1445588327.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/3wdtq1445588327.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.7149314156 0.4500253686 0.3266362232 0.2240915919 [6] 0.1123841270 0.1068803431 0.0820371587 0.0483735704 0.0338542175 [11] 0.0841253535 0.1462930543 0.1666528437 0.0611701914 -0.1141097447 [16] -0.2117599067 -0.1972761471 -0.1905622302 -0.1663175979 -0.1733633599 [21] -0.1843208062 -0.2033967500 -0.1481796343 -0.0591825873 -0.0106447050 [26] -0.0476081020 -0.0928087515 -0.1048185896 -0.0373309873 -0.0132023774 [31] 0.0104286587 0.0166089198 0.0091127888 0.0135196630 0.0184997351 [36] 0.0595322447 0.0894184177 -0.0312845531 -0.1443224240 -0.1698825607 [41] -0.1405462042 -0.1484035344 -0.1035808068 -0.0824459097 -0.0914681513 [46] -0.1236861412 -0.0675401700 -0.0425362329 -0.0704571643 -0.0803707245 [51] -0.1175437248 -0.1415838184 -0.0996897357 -0.0605695655 -0.0690741461 [56] -0.0318069701 0.0029957577 -0.0004508265 0.0350743906 0.0868621503 [61] 0.0970231406 > (mypacf <- c(rpacf$acf)) [1] 0.7149314156 -0.1249845084 0.1122985181 -0.0559703287 -0.0618039267 [6] 0.1329647956 -0.0779720417 0.0227573478 -0.0030168030 0.1115045155 [11] 0.0962102937 -0.0067631598 -0.2021086683 -0.2322920538 -0.0279193857 [16] 0.0828646880 -0.0245219986 0.0119042121 -0.1344333839 -0.0092698816 [21] -0.0593032308 0.0573600764 0.0626682266 -0.0009203039 -0.0194271844 [26] -0.0050342230 0.0247415260 0.0889193270 -0.1083779796 0.0394568226 [31] -0.0113067440 0.0367398990 0.0585307669 -0.1442812490 0.0468234671 [36] -0.0372222408 -0.2056560710 -0.0294580487 -0.0774958402 0.0458184889 [41] -0.0918679805 0.0771832786 -0.0329515255 -0.0454009147 -0.0370251626 [46] 0.0414682090 -0.0048158406 -0.0576054309 0.1339623523 -0.0481686974 [51] -0.0209050025 -0.0193445232 -0.0753867227 -0.0640792874 0.0991413901 [56] -0.0243484320 0.0317480876 -0.0321327367 -0.0391754154 0.0221338511 > 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/4mkgc1445588327.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/5f81f1445588327.tab") > > try(system("convert tmp/1a90u1445588327.ps tmp/1a90u1445588327.png",intern=TRUE)) character(0) > try(system("convert tmp/290vo1445588327.ps tmp/290vo1445588327.png",intern=TRUE)) character(0) > try(system("convert tmp/3wdtq1445588327.ps tmp/3wdtq1445588327.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.252 0.239 1.475