R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 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(46.56,46.72,47.01,47.26,47.49,47.51,47.52,47.66,47.71,47.87,48,48,48.05,48.25,48.72,48.94,49.16,49.18,49.25,49.34,49.49,49.57,49.63,49.67,49.7,49.8,50.09,50.49,50.73,51.12,51.15,51.41,51.61,52.06,52.17,52.18,52.19,52.74,53.05,53.38,53.78,53.82,53.88,53.96,54.14,54.2,54.35,54.36,54.39,54.77,54.91,55.06,55.38,55.41,55.47,55.58,55.67,55.97,56.03,56.06,56.08,56.43,56.65,56.96,57.37,57.51,57.61,57.7,57.91,58.12,58.18,58.16) > 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/1fc0g1356537518.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/2191j1356537518.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/3ovgd1356537518.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.217586204 -0.001720281 -0.172153277 -0.106222243 [6] -0.013437656 0.098536535 -0.064457381 -0.238190989 -0.207951539 [11] -0.139030170 0.215586024 0.396846038 0.174234616 -0.142778847 [16] -0.088768071 -0.262583843 0.003419625 -0.010745128 -0.044662740 [21] -0.140000058 -0.293912697 -0.185466149 0.181152466 0.374437605 [26] 0.140001063 0.018641560 -0.174128135 -0.099959086 -0.034180488 [31] 0.116965361 -0.022949137 -0.133147317 -0.141864384 -0.063243347 [36] 0.257760229 0.225041562 0.124718190 -0.023328376 -0.094833828 [41] -0.097339950 -0.030467275 0.001626270 -0.017643457 -0.141280847 [46] -0.075681712 -0.053733252 0.094854704 0.138998239 > (mypacf <- c(rpacf$acf)) [1] 0.217586204 -0.051502352 -0.168980667 -0.034222513 0.015412250 [6] 0.074970603 -0.135401502 -0.224237278 -0.098583783 -0.104624296 [11] 0.211492169 0.290857435 0.018009809 -0.180581472 0.028014212 [16] -0.299378039 -0.038308098 -0.109816203 0.000140902 0.088215721 [21] -0.228306854 -0.138849180 0.084397017 0.070171845 -0.024440584 [26] 0.006946085 -0.120139082 0.026082704 -0.137912108 -0.034954156 [31] 0.022114113 -0.134601864 0.232150177 0.015751568 0.028067539 [36] -0.068024023 -0.166852074 -0.012809275 -0.037455614 -0.008754876 [41] -0.003379745 -0.028658725 -0.104550103 -0.020031548 0.031769134 [46] -0.045410974 -0.067816499 -0.140231695 > 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/4yn121356537518.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/5i6by1356537518.tab") > > try(system("convert tmp/1fc0g1356537518.ps tmp/1fc0g1356537518.png",intern=TRUE)) character(0) > try(system("convert tmp/2191j1356537518.ps tmp/2191j1356537518.png",intern=TRUE)) character(0) > try(system("convert tmp/3ovgd1356537518.ps tmp/3ovgd1356537518.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.731 0.270 2.028