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(204.12,203.27,203.73,203.7,203.44,203.34,203.34,203.05,202.71,202.51,203.45,203.04,203.04,202.87,202.92,202.87,203.17,203.88,203.88,203.45,203.22,202.11,202.5,202.86,202.86,203.8,203.78,204.53,204.44,204.14,204.14,204.04,204.68,205.01,204.93,204.34,204.34,203.87,202.47,201.95,201.86,200.33,200.33,200.33,200.75,201.86,202.77,202.85,202.85,202.84,202.94,203.05,203.45,204.19,204.18,204.47,204.78,206.05,206.32,206.36,205.21,205.35,205.94,204.57,204.27,204.86,204.66,204.79,205.58,205.63,205.12,204.96) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/16f2r1413583855.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/261j51413583856.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/3xl8q1413583856.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.147112946 0.009446345 0.139485789 -0.072679045 [6] -0.143454158 -0.096651238 -0.011457373 -0.047297088 -0.090532244 [11] 0.045003712 -0.069385747 0.023233133 -0.028809322 -0.168912901 [16] -0.085566275 -0.206323656 -0.012236285 -0.130140311 -0.028018352 [21] 0.142684928 -0.023639170 0.199443081 0.098694665 -0.169417147 [26] 0.054842571 -0.009215303 -0.102104944 0.039339103 0.087818949 [31] 0.101014470 -0.075189393 0.063579393 -0.009258800 0.079201750 [36] 0.059019788 -0.039257730 -0.002353966 -0.108676526 -0.004496935 [41] 0.107996853 -0.010651593 0.071556090 0.033290683 -0.071935286 [46] -0.020468999 -0.076675687 -0.027324755 -0.022390248 > (mypacf <- c(rpacf$acf)) [1] 0.1471129463 -0.0124656589 0.1430298745 -0.1194186626 -0.1163945868 [6] -0.0855805741 0.0417104462 -0.0235965328 -0.0805837311 0.0354930202 [11] -0.1009728411 0.0726231907 -0.0864051132 -0.1580966085 -0.0808176581 [16] -0.2055876480 0.0834272849 -0.2051549348 0.0218693247 0.0170146609 [21] -0.0726142888 0.1918755349 -0.0943635008 -0.2062125805 0.0200705864 [26] -0.0210728231 -0.0909419083 0.0712793714 -0.0455153326 0.0468304883 [31] -0.1009732724 -0.0780225789 -0.0413998524 0.1217507727 0.0018498032 [36] 0.0360304077 -0.0738751534 -0.0996116370 0.1022177115 0.0607090846 [41] 0.0546997770 -0.0785962530 0.0135956208 -0.0009569006 -0.0431742689 [46] 0.0411933321 -0.0584764444 0.0411902435 > 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/4z3g41413583856.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/57dnj1413583856.tab") > > try(system("convert tmp/16f2r1413583855.ps tmp/16f2r1413583855.png",intern=TRUE)) character(0) > try(system("convert tmp/261j51413583856.ps tmp/261j51413583856.png",intern=TRUE)) character(0) > try(system("convert tmp/3xl8q1413583856.ps tmp/3xl8q1413583856.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.259 0.175 1.451