R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(2.07,2.2,2.29,2.32,2.37,2.38,2.38,2.28,2.22,2.25,2.3,2.3,2.23,2.27,2.3,2.32,2.41,2.43,2.45,2.47,2.46,2.5,2.46,2.43,2.37,2.45,2.53,2.56,2.62,2.67,2.62,2.6,2.53,2.49,2.48,2.44,2.36,2.35,2.44,2.5,2.58,2.55,2.44,2.3,2.24,2.19,2.25,2.28,2.27,2.37,2.47,2.5,2.47,2.61,2.61,2.65,2.43,2.43,2.33,2.27,2.22,2.17,2.28,2.3,2.33,2.44,2.41,2.4,2.34,2.37,2.38,2.3,2.29,2.34,2.35,2.38,2.37,2.45,2.51,2.46,2.42,2.48,2.44,2.43,2.36,2.42,2.42,2.43,2.47,2.54,2.55,2.55,2.49,2.54,2.55,2.5) > 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/1b2nq1426155278.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/2uu9j1426155278.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/36ktg1426155278.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.819270706 0.607775091 0.390709845 0.206221980 [6] 0.045707408 -0.058864312 -0.058616253 -0.018027133 0.014266462 [11] 0.079180854 0.161304973 0.219547281 0.162427518 0.055086488 [16] -0.047750149 -0.183154863 -0.311980528 -0.374899407 -0.366113935 [21] -0.309760215 -0.243730967 -0.135751169 -0.014465968 0.063936793 [26] 0.021452817 -0.053531012 -0.131155454 -0.197094835 -0.279203512 [31] -0.310190045 -0.305473257 -0.248910211 -0.182556894 -0.073994084 [36] 0.033322072 0.114636796 0.098158904 0.032501726 -0.030381490 [41] -0.096548803 -0.145272255 -0.158235015 -0.133247684 -0.099558580 [46] -0.090946771 -0.071034442 -0.008965337 0.052171877 > (mypacf <- c(rpacf$acf)) [1] 0.8192707057 -0.1929144292 -0.1428854138 -0.0497229857 -0.0903993018 [6] 0.0111178393 0.1897242602 0.0283550184 -0.0673817390 0.1288717223 [11] 0.0973824443 0.0019994861 -0.2429150908 -0.1139269399 -0.0030677986 [16] -0.1626183468 -0.0737261700 0.0493038426 -0.0334176900 0.0005899213 [21] 0.0213508912 0.0594607207 0.0197234225 -0.0236642909 -0.2467344486 [26] -0.0434104224 0.0032189113 0.0723538169 -0.0841502980 -0.0354575930 [31] -0.0993432682 0.0742350296 0.0075367994 0.0400043817 -0.0875500099 [36] -0.0155027687 -0.1243351985 -0.0652439679 0.0483897179 0.0175506083 [41] 0.0162582085 -0.0360349717 -0.0340582111 -0.0730601358 -0.1385868827 [46] -0.1258486593 0.0479348899 0.0204872363 > 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/46s3a1426155278.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/5qp0n1426155278.tab") > > try(system("convert tmp/1b2nq1426155278.ps tmp/1b2nq1426155278.png",intern=TRUE)) character(0) > try(system("convert tmp/2uu9j1426155278.ps tmp/2uu9j1426155278.png",intern=TRUE)) character(0) > try(system("convert tmp/36ktg1426155278.ps tmp/36ktg1426155278.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.165 0.239 1.385