R version 3.2.3 (2015-12-10) -- "Wooden Christmas-Tree" 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(99.2,99.1,99.1,99.1,99.1,99.1,99.9,100,100,101.3,102,102,102.4,103,103,103.6,103.6,103.6,103.6,103.6,103.9,104,104,104,104.9,105.1,105.2,105.5,105.7,105.7,105.7,105.7,105.7,105.8,105.8,105.8,106.6,107,107.2,107.3,107.3,107.3,107.4,107.4,107.4,107.4,107.5,107.5,105,105.2,105.2,105.3,105.3,105.3,105.3,105.3,105.3,105.3,106.1,106.1) > 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/1jzk81452267681.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/2tdzj1452267681.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/3psf21452267681.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.94579178 0.88648380 0.82844178 0.76364176 0.69401095 [7] 0.62253004 0.55869961 0.49390474 0.42815912 0.37653589 0.33887231 [13] 0.30123614 0.25824326 0.22082121 0.18050926 0.14386665 0.10516839 [19] 0.06495407 0.02128454 -0.02377257 -0.06442543 -0.10438450 -0.14593499 [25] -0.18599170 -0.20681600 -0.22640861 -0.24655454 -0.26567435 -0.28196935 [31] -0.29962621 -0.31990405 -0.34190350 -0.36379845 -0.38026989 -0.39855202 [37] -0.41189885 -0.40878669 -0.40107842 -0.38697362 -0.36323291 -0.33901427 [43] -0.31430740 -0.28352434 -0.25438581 -0.22527297 -0.19487021 -0.16396724 [49] -0.13100347 > (mypacf <- c(rpacf$acf)) [1] 0.945791778 -0.076208204 -0.017216372 -0.097398520 -0.077361530 [6] -0.057713384 0.033460154 -0.052049518 -0.045342166 0.084560947 [11] 0.083245662 -0.037978918 -0.091282079 -0.004275177 -0.084387533 [16] 0.019811065 -0.049402130 -0.054040287 -0.074653641 -0.017744255 [21] 0.007305843 -0.044463945 -0.065985913 -0.041060913 0.142759818 [26] -0.034601314 -0.038449205 -0.079429599 -0.028631990 -0.055771026 [31] -0.028175786 -0.084760753 -0.065504224 0.055665570 -0.014189535 [36] 0.009395346 0.082339499 0.010917344 0.014439139 0.081643132 [41] -0.059538362 -0.046209646 0.043487447 -0.020564391 0.006599802 [46] 0.038561849 0.024859249 0.027267432 > 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/4ff6l1452267681.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/5vx3g1452267681.tab") > > try(system("convert tmp/1jzk81452267681.ps tmp/1jzk81452267681.png",intern=TRUE)) character(0) > try(system("convert tmp/2tdzj1452267681.ps tmp/2tdzj1452267681.png",intern=TRUE)) character(0) > try(system("convert tmp/3psf21452267681.ps tmp/3psf21452267681.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.369 0.282 1.645