R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(29358,28673,30383,30988,32565,32510,31584,32729,34977,36710,39457,39217,40435,41373,43221,43271,43605,42254,41702,41002,39804,40256,40740,42362,41126,40225,41216,39148,41591,39506,35261,34148,33947,32819,32700,32242,32810,33865,32226,31077,31293,30236,30160,32436,30695,27525,26434,25739,25204,24977,24320,22680,22052,21467,21383,21777,21928,21814,22937,23595,20830) > 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/1815w1395088636.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/2djnn1395088636.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/3myii1395088636.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.954198466 0.911067547 0.865296660 0.809151804 [6] 0.754158671 0.691810845 0.617240057 0.543323601 0.473886247 [11] 0.405608317 0.347043763 0.288546420 0.227459061 0.170278570 [16] 0.111901589 0.049632724 0.000565408 -0.035060062 -0.082065990 [21] -0.129811697 -0.173063923 -0.219099081 -0.257001596 -0.280229907 [26] -0.310478574 -0.339938867 -0.364793813 -0.392104810 -0.408425755 [31] -0.425410153 -0.445268788 -0.446356455 -0.435124198 -0.438252180 [36] -0.430795978 -0.426217199 -0.413835273 -0.386759592 -0.363674839 [41] -0.341837193 -0.320763112 -0.293371798 -0.259117262 -0.217133435 [46] -0.170479612 -0.129313509 -0.088345309 -0.054390644 > (mypacf <- c(rpacf$acf)) [1] 0.9541984657 0.0064000099 -0.0512358882 -0.1423863786 -0.0249965934 [6] -0.1087865771 -0.1724163976 -0.0531345974 0.0235144915 -0.0032692517 [11] 0.0693926289 -0.0218378357 -0.0646186903 -0.0380282618 -0.0821582353 [16] -0.1276967085 0.0585529124 0.1424993587 -0.1374238866 -0.1089963776 [21] -0.0039418219 -0.0668554959 -0.0395523910 0.1041184607 -0.0691695955 [26] -0.0636290247 0.0003325126 -0.0555717301 -0.0106268887 -0.0868144303 [31] -0.0640633555 0.1449039565 0.1770827932 -0.1482189722 -0.0277142185 [36] -0.1359257151 0.0733019073 0.0960779747 -0.0739166462 0.0202896547 [41] 0.0010024170 0.0317452072 0.0625877617 0.0494346649 0.0726423562 [46] -0.0408755453 -0.0660615343 -0.0877408758 > 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/4o1xc1395088636.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/5vbtm1395088636.tab") > > try(system("convert tmp/1815w1395088636.ps tmp/1815w1395088636.png",intern=TRUE)) character(0) > try(system("convert tmp/2djnn1395088636.ps tmp/2djnn1395088636.png",intern=TRUE)) character(0) > try(system("convert tmp/3myii1395088636.ps tmp/3myii1395088636.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 3.042 0.669 3.673