R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(9.11,9.06,9.11,9.13,9.13,9.19,9.2,9.23,9.24,9.28,9.32,9.32,9.32,9.36,9.37,9.38,9.41,9.44,9.44,9.44,9.47,9.48,9.56,9.58,9.56,9.58,9.7,9.74,9.76,9.78,9.84,9.88,9.96,9.97,9.96,9.96,9.96,10.02,10.08,10.09,10.12,10.14,10.17,10.22,10.25,10.25,10.26,10.34,10.33,10.3,10.33,10.33,10.37,10.44,10.45,10.45,10.44,10.43,10.4,10.43,10.47,10.52,10.55,10.5,10.44,10.47,10.5,10.54,10.55,10.53,10.54,10.54,10.54,10.59,10.72,10.76,10.78,10.78,10.78,10.82,10.81,10.85) > 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/138zl1363717568.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/282pp1363717568.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/39ndx1363717568.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.965095796 0.927528469 0.890712397 0.855072922 [6] 0.818331269 0.782149373 0.744806758 0.708146063 0.675025647 [11] 0.643782951 0.613089321 0.581736086 0.549332776 0.516127457 [16] 0.482015713 0.447766651 0.414721900 0.382860182 0.347945287 [21] 0.310535726 0.273879391 0.237422961 0.204107206 0.171460606 [26] 0.135608563 0.099608719 0.067493435 0.035488898 0.003440768 [31] -0.026287171 -0.053557498 -0.080061729 -0.102907149 -0.127322752 [36] -0.153585248 -0.178175534 -0.203377577 -0.227007050 -0.247813975 [41] -0.267191150 -0.285061872 -0.301992125 -0.317394648 -0.331196993 [46] -0.342702501 -0.352971938 -0.363161557 -0.370955114 > (mypacf <- c(rpacf$acf)) [1] 0.965095796 -0.056588720 -0.007071812 -0.003135025 -0.036471627 [6] -0.010393078 -0.038059181 -0.010450075 0.029885690 0.003121321 [11] -0.010992469 -0.028002881 -0.035037244 -0.031877902 -0.036581488 [16] -0.024288109 -0.003398374 -0.004710029 -0.067006952 -0.059056574 [21] -0.017226432 -0.030968284 0.015632344 -0.021293494 -0.072842488 [26] -0.025094144 0.019565270 -0.038510231 -0.032410037 0.003578351 [31] 0.008222189 -0.016161911 0.022159044 -0.055544482 -0.053681744 [36] -0.005426897 -0.045170228 -0.001455500 0.014698459 -0.008483199 [41] -0.007197617 -0.025097911 -0.006608003 -0.004521033 -0.002588586 [46] -0.009480516 -0.022786109 0.012442090 > 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/4pcod1363717568.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/5jdpk1363717568.tab") > > try(system("convert tmp/138zl1363717568.ps tmp/138zl1363717568.png",intern=TRUE)) character(0) > try(system("convert tmp/282pp1363717568.ps tmp/282pp1363717568.png",intern=TRUE)) character(0) > try(system("convert tmp/39ndx1363717568.ps tmp/39ndx1363717568.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.678 0.283 1.946