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(340.7,343.5,345.3,346.9,349,351.4,353,355,360.1,364.7,366.5,369,369.9,370.8,374.5,378.4,381.3,383.5,387.6,391.7,395.4,399.3,403.3,406.6,410.5,413.5,418.7,421.7,422.8,425.8,427.6,431,434.3,437.6,440.4,443.5,446.2,446.2,449.7,454.2,458.4,461.1,464,466.2,468.7,471.8,474.9,477.5,480,482.8,485.7,488.5,492,495.1,498.5,502.2,502.1,510,515,520.4,525.2,530.1,534.5,538.5,544.4,548.4,551.9,554.9,558.1,561.3,564.4,567,568.7,570.9,572.5,574.6,577.1,580.9,583.3,586.5) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '4' > par4 = '1' > par3 = '0' > par2 = '1' > par1 = '36' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '4' > par4 <- '1' > par3 <- '0' > par2 <- '1' > par1 <- '36' > #'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/17vax1445587187.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/28mdd1445587187.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/3tdy61445587187.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.8524915000 0.6613406974 0.4616727097 0.2932958539 [6] 0.2475069786 0.2030725407 0.1293110175 -0.0001693659 -0.1224240495 [11] -0.2329384560 -0.3043206404 -0.3240504883 -0.3454688059 -0.3584139409 [16] -0.3327619480 -0.2779640181 -0.2038522681 -0.1282184221 -0.1002583934 [21] -0.1215206151 -0.1243856787 -0.1064996189 -0.0455265854 0.0221788078 [26] 0.0351748252 -0.0036353414 -0.0890465673 -0.1178730180 -0.1105700054 [31] -0.0449246931 0.0372488016 0.0593979505 0.0739420799 0.0607586256 [36] 0.0777694561 0.1322478068 > (mypacf <- c(rpacf$acf)) [1] 0.852491500 -0.239337923 -0.128168003 -0.009151676 0.322664099 [6] -0.189002523 -0.218453920 -0.238003866 0.187995934 -0.145988655 [11] -0.122806629 -0.083813463 0.048615307 -0.069043005 0.144795899 [16] 0.049630829 0.009710865 -0.104760763 -0.071601982 -0.121280411 [21] 0.115477556 -0.058194124 0.044830557 -0.164855290 -0.060089300 [26] -0.097098694 -0.046968691 0.155743157 -0.023087273 0.067194095 [31] -0.006247962 0.032104825 0.036775337 -0.022192845 0.052360946 [36] 0.080269756 > 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/4jwpw1445587187.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/5eduv1445587187.tab") > > try(system("convert tmp/17vax1445587187.ps tmp/17vax1445587187.png",intern=TRUE)) character(0) > try(system("convert tmp/28mdd1445587187.ps tmp/28mdd1445587187.png",intern=TRUE)) character(0) > try(system("convert tmp/3tdy61445587187.ps tmp/3tdy61445587187.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.099 0.235 1.341