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(45.3,49.9,53.8,55.1,52.9,53.5,53.8,52,48.2,45.5,45.7,52.5,52.3,54.8,54.7,54.9,54.9,64.2,66.4,69.1,68.3,77.3,89.6,93,96.1,131.3,125.3,126,138.3,163,182.5,164.6,148.8,109.3,93.5,80.2,84,75.5,62.4,64.2,64.7,71,73.7,72.6,68.1,72.3,78.5,81.9,97.8,93.1,94.2,101.1,101,99.7,97.1,91.7,95,98.9,109,121.9,131.5,128.5,128.4,126.4,123.1,123,123.3,123.6,124.9,120.4,114.9,113.4) > 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/1d0f41354102123.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/273qo1354102123.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/39llw1354102123.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.940218620 0.848475322 0.740747812 0.632407670 [6] 0.522127715 0.408171176 0.296796774 0.184741733 0.087442760 [11] 0.003572767 -0.064387820 -0.129321933 -0.188883718 -0.226830812 [16] -0.251561061 -0.260288972 -0.261145793 -0.257857999 -0.258344254 [21] -0.260484678 -0.261868338 -0.253150135 -0.234096685 -0.221770849 [26] -0.199819694 -0.146691811 -0.091649285 -0.030770401 0.032330221 [31] 0.099904446 0.171832004 0.228217697 0.276109524 0.300277251 [36] 0.306389140 0.295343026 0.284448301 0.257246149 0.213123505 [41] 0.158063566 0.099895475 0.041634099 -0.008113273 -0.052161747 [46] -0.092948348 -0.130193271 -0.166402709 -0.190857944 > (mypacf <- c(rpacf$acf)) [1] 9.402186e-01 -3.063717e-01 -1.270847e-01 -1.547038e-02 -8.681666e-02 [6] -1.072504e-01 -3.825728e-02 -1.036009e-01 4.656747e-02 -1.459233e-02 [11] 2.790353e-05 -1.126531e-01 -4.282479e-02 1.095457e-01 -3.789556e-02 [16] 1.340774e-02 -1.648931e-02 -4.766847e-02 -8.308733e-02 -4.444973e-02 [21] -4.861764e-02 6.980881e-02 3.969819e-02 -1.099893e-01 9.836583e-02 [26] 2.953791e-01 -1.443483e-01 4.511453e-02 1.000054e-01 5.568495e-02 [31] 9.844494e-02 -1.513641e-01 -3.408303e-03 -9.751334e-02 -1.908806e-02 [36] -1.486130e-02 3.938029e-02 -1.072061e-01 1.833799e-02 -6.312954e-02 [41] 5.890004e-02 -4.785427e-02 9.482307e-02 -3.952326e-02 -4.556030e-02 [46] -2.651973e-02 -1.124572e-02 1.425132e-02 > 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/4clmx1354102123.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/5kxl41354102123.tab") > > try(system("convert tmp/1d0f41354102123.ps tmp/1d0f41354102123.png",intern=TRUE)) character(0) > try(system("convert tmp/273qo1354102123.ps tmp/273qo1354102123.png",intern=TRUE)) character(0) > try(system("convert tmp/39llw1354102123.ps tmp/39llw1354102123.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.785 0.372 2.136