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(73.97,75.01,75.98,78.85,79.34,79.62,79.76,79.62,79.89,79.88,79.97,79.63,80.04,80.23,80.44,81.78,82.51,82.43,82.35,82.53,82.08,82.73,82.46,81.98,82.11,82.26,82.51,82.89,83.83,84.73,84.48,84.84,84.99,84.7,84.54,84.73,84.51,84.54,84.27,84.47,84.25,84.33,84.29,84.53,84.01,84.18,84.08,83.44,83.61,83.89,83.4,82.96,82.76,83.35,87.78,88.99,88.92,88.91,89.79,90.54,93.15,92.79,93.21,95.35,100.91,103.69,104.04,104.16,104.71,105.18,104.92,104.83,104.9,105.05,104.6,103.21,102.52,101.09,101.19,102.34,102.62,102.47,101.82,101.86,101.54,101.98,101.23,100.4,99.94,99.94,100,98.8,99.07,99.46,99.18,98.47,97.12,96.91,96.09,97.17,96.8,97.13,99.9,100.56,100.84,99.81,100.44,100.07) > 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/1es4k1445608229.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/2zkjw1445608229.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/3pia31445608229.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.973999813 0.944080480 0.914540126 0.888403260 [6] 0.861046778 0.832240464 0.804885520 0.777599061 0.750722040 [11] 0.722598818 0.691084074 0.657942509 0.624650982 0.591732572 [16] 0.558268537 0.527413539 0.498456611 0.469469659 0.441411736 [21] 0.413662242 0.385249812 0.357728745 0.330510088 0.303653671 [26] 0.277101680 0.249788572 0.222205327 0.196252725 0.172790923 [31] 0.152101745 0.131131281 0.110530491 0.091097089 0.070142402 [36] 0.048656052 0.026829506 0.004188569 -0.019307119 -0.045857525 [41] -0.074206890 -0.102720747 -0.130052703 -0.157233388 -0.181338901 [46] -0.201268828 -0.219247320 -0.236982506 -0.256520817 > (mypacf <- c(rpacf$acf)) [1] 0.973999813 -0.089531682 -0.002311546 0.049887674 -0.047691657 [6] -0.038008963 0.020918998 -0.022747209 -0.009323982 -0.035268124 [11] -0.081500460 -0.041835338 -0.021536241 -0.021596324 -0.031047085 [16] 0.035112948 0.007524733 -0.027645316 0.007087892 -0.012205257 [21] -0.034939159 0.008492113 -0.015186995 -0.017358024 -0.009952648 [26] -0.043794014 -0.033202565 0.011359263 0.017610631 0.025808622 [31] -0.022600630 -0.005867158 0.002508198 -0.056858191 -0.022901108 [36] -0.021300872 -0.042598483 -0.039342292 -0.091037818 -0.067904510 [41] -0.034329890 -0.021578246 -0.033862892 0.041963891 0.057866095 [46] 0.006437433 -0.011815062 -0.043148744 > 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/496gf1445608229.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/5kd191445608229.tab") > > try(system("convert tmp/1es4k1445608229.ps tmp/1es4k1445608229.png",intern=TRUE)) character(0) > try(system("convert tmp/2zkjw1445608229.ps tmp/2zkjw1445608229.png",intern=TRUE)) character(0) > try(system("convert tmp/3pia31445608229.ps tmp/3pia31445608229.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.229 0.205 1.444