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(85.95,86.41,86.42,86.81,86.71,86.7,87.07,86.96,87.04,87.5,88.32,88.56,88.92,89.56,90.21,90.42,91.23,91.73,92.21,91.65,91.8,91.63,91.09,90.89,90.98,91.29,90.77,90.96,90.89,90.72,90.66,90.94,90.7,90.74,90.98,91.13,91.54,91.93,92.27,92.59,92.96,92.95,92.99,93.05,93.34,93.47,93.59,93.96,94.49,95.04,95.52,95.75,96.07,96.37,96.48,96.4,96.66,96.81,97.19,97.23,97.94,98.52,98.73,98.8,98.77,98.54,98.72,99.15,99.32,99.5,99.39,99.4,99.37,99.69,99.83,99.79,99.94,100.11,100.21,100.15,100.21,100.13,100.2,100.36,100.5,100.66,100.72,100.41,100.3,100.38,100.55,100.17,100.09,100.22,100.09,99.98) > 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/148ky1445622357.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/2tlku1445622357.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/3a2881445622357.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.97276344 0.94506627 0.91525952 0.88565989 0.85362171 [7] 0.81973957 0.78687485 0.75223405 0.71667979 0.68143446 0.64889426 [13] 0.61662900 0.58559802 0.55677671 0.53029072 0.50372622 0.48043105 [19] 0.45849679 0.43863290 0.41636958 0.39460821 0.37136677 0.34520601 [25] 0.31810485 0.29018442 0.26294169 0.23260401 0.20299501 0.17307947 [31] 0.14302633 0.11256815 0.08223293 0.05009705 0.01726437 -0.01475413 [37] -0.04551114 -0.07387331 -0.10134325 -0.12701354 -0.15147656 -0.17443210 [43] -0.19794150 -0.22165408 -0.24509108 -0.26731214 -0.28891275 -0.30961772 [49] -0.32796534 > (mypacf <- c(rpacf$acf)) [1] 0.9727634356 -0.0223786131 -0.0534506984 -0.0111071190 -0.0598212653 [6] -0.0515929377 0.0040642457 -0.0500415515 -0.0367398790 -0.0093569661 [11] 0.0298617828 -0.0145750649 0.0038745995 0.0215274868 0.0190626419 [16] -0.0242509692 0.0413183380 0.0016101611 0.0114086304 -0.0629671975 [21] -0.0127087565 -0.0509896918 -0.0754485743 -0.0331573533 -0.0293084601 [26] -0.0105814871 -0.0636280780 -0.0003350179 -0.0186228221 -0.0245367694 [31] -0.0187832526 -0.0203121164 -0.0676731938 -0.0431615918 -0.0119030908 [36] -0.0181756133 0.0056181768 -0.0156359569 -0.0060920081 -0.0168862211 [41] -0.0089608040 -0.0381272580 -0.0479585968 -0.0296378829 -0.0139779052 [46] -0.0179564670 -0.0190025276 0.0150494930 > 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/4bhel1445622357.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/50m641445622357.tab") > > try(system("convert tmp/148ky1445622357.ps tmp/148ky1445622357.png",intern=TRUE)) character(0) > try(system("convert tmp/2tlku1445622357.ps tmp/2tlku1445622357.png",intern=TRUE)) character(0) > try(system("convert tmp/3a2881445622357.ps tmp/3a2881445622357.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.176 0.245 1.427