R version 3.3.1 (2016-06-21) -- "Bug in Your Hair" Copyright (C) 2016 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(540,520,550,440,570,560,600,620,690,600,570,710,600,450,530,400,560,460,610,550,580,650,640,760,550,460,510,370,530,410,580,550,490,700,630,720,540,500,450,370,490,440,600,580,500,670,620,800,640,390,390,390,460,460,620,570,510,640,590,850,670,390,410,340,470,540,680,670,540,630,560,800,610,490,440,330,490,590,690,650,480,690,540,830,690,500,460,310,490,470,710,710,540,700,520,810,690,510,390,270,530,510,670,770,570,640,480,830) > 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.327 (Mon, 30 Nov 2015 06:58:35 +0000) > #Author: root > #To cite this work: Wessa P., (2015), (Partial) Autocorrelation Function (v1.0.12) 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) > x <- na.omit(x) > 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/14obg1471288606.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/2jmlo1471288606.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/3al4y1471288606.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.33666252 0.16905725 -0.23179385 -0.38278568 -0.13150358 [7] -0.33855635 -0.07743736 -0.35464083 -0.21790430 0.13326714 0.29163814 [13] 0.82222175 0.31966267 0.19079636 -0.21197686 -0.37862457 -0.12342631 [19] -0.30249947 -0.04399535 -0.27173381 -0.18108454 0.08735818 0.21648687 [25] 0.66566936 0.31637728 0.19246186 -0.18306308 -0.35035793 -0.14991405 [31] -0.27506762 -0.05108291 -0.20154335 -0.12951734 0.07878343 0.15858565 [37] 0.55652305 0.27727644 0.13592507 -0.14519105 -0.30542524 -0.16485147 [43] -0.27174131 -0.02770578 -0.12625996 -0.07366218 0.07088212 0.10835015 [49] 0.42218738 > (mypacf <- c(rpacf$acf)) [1] 0.336662520 0.062837726 -0.346809981 -0.279258418 0.207077515 [6] -0.405723303 -0.104223905 -0.444313821 -0.286190688 0.159992314 [11] 0.123630981 0.571131985 -0.098578314 -0.005205219 0.026664331 [16] -0.017875920 0.121990272 0.018679707 -0.015145064 0.166723489 [21] -0.017056543 -0.054663650 -0.002628757 -0.055507551 0.129475168 [26] -0.016448122 -0.066876401 0.058532151 -0.089156269 -0.003810126 [31] -0.113288553 -0.012498323 0.110422372 0.001264829 -0.085368564 [36] 0.075844136 -0.152473746 -0.135010592 0.083280592 -0.003349235 [41] -0.017895679 -0.100266328 0.062624878 0.056929005 -0.027335742 [46] -0.106975923 -0.058907510 -0.030832523 > 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/4rhvp1471288606.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/53y5l1471288607.tab") > > try(system("convert tmp/14obg1471288606.ps tmp/14obg1471288606.png",intern=TRUE)) character(0) > try(system("convert tmp/2jmlo1471288606.ps tmp/2jmlo1471288606.png",intern=TRUE)) character(0) > try(system("convert tmp/3al4y1471288606.ps tmp/3al4y1471288606.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.235 0.122 1.372