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(7.72,7.67,7.84,7.79,7.83,7.94,8.02,8.06,8.12,8.13,7.97,8.01,8,7.9,7.99,8.02,8.08,8.02,8.07,8.11,8.19,8.16,8.08,8.22,8.15,8.19,8.31,8.3,8.34,8.31,8.38,8.34,8.44,8.64,8.6,8.61,8.54,8.69,8.73,8.91,9.01,9.08,8.94,9.03,9.02,8.96,9.03,8.94,8.95,8.95,8.99,8.93,8.98,8.95,9.02,8.92,9.1,9.06,8.97,8.89,8.99,8.79,8.83,8.61,8.71,8.91,8.91,8.89,8.98,9,8.99,8.88) > 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/fisher/rcomp/tmp/172qj1353677804.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/fisher/rcomp/tmp/21z0r1353677804.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/fisher/rcomp/tmp/3p5zv1353677804.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.0000000000 -0.2379017612 0.0816749546 -0.0430668943 0.0683264451 [6] -0.1301600384 0.0385848131 -0.0486926226 0.0389338635 -0.0101222529 [11] 0.0258881164 -0.0344068356 0.0841746707 0.0321544122 0.0710434665 [16] -0.1002847356 0.0232386354 0.0267386643 -0.0550963719 0.0601791636 [21] -0.1676850453 0.1302490376 -0.2137245760 -0.0016749257 -0.0412819232 [26] 0.0483711180 -0.0124121605 0.0342022199 -0.0179376787 -0.0499853812 [31] -0.0737535069 -0.0125186295 0.0731203675 -0.0013507044 -0.0005999539 [36] 0.0657037532 -0.0202014849 0.0435018833 -0.0587207866 0.0406841359 [41] -0.0789302842 0.0294574052 0.0786721246 -0.1487477072 0.0080062858 [46] 0.0034806679 0.0194940648 -0.0603949902 0.0554982784 > (mypacf <- c(rpacf$acf)) [1] -2.379018e-01 2.658219e-02 -1.891180e-02 5.524434e-02 -1.063250e-01 [6] -2.148560e-02 -3.407767e-02 1.533837e-02 1.727186e-02 1.119322e-02 [11] -2.417370e-02 6.473239e-02 7.904306e-02 9.564110e-02 -6.624762e-02 [16] -3.443213e-02 5.080760e-02 -3.452427e-02 7.112996e-02 -1.724363e-01 [21] 5.418410e-02 -1.835269e-01 -1.124540e-01 -3.496232e-02 -2.708820e-02 [26] 1.923888e-02 -2.095780e-02 -2.011621e-06 -8.143810e-02 -1.081463e-01 [31] -6.265534e-02 1.297413e-01 4.168723e-02 5.940899e-02 6.307685e-02 [36] 5.614676e-02 7.210171e-02 -7.084463e-02 6.942938e-02 -1.131494e-01 [41] 5.602227e-02 8.649825e-02 -1.276855e-01 -1.179962e-01 -1.412876e-01 [46] -3.845693e-02 -6.603946e-02 -7.501126e-03 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4i2cv1353677804.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/fisher/rcomp/tmp/5qb4o1353677804.tab") > > try(system("convert tmp/172qj1353677804.ps tmp/172qj1353677804.png",intern=TRUE)) character(0) > try(system("convert tmp/21z0r1353677804.ps tmp/21z0r1353677804.png",intern=TRUE)) character(0) > try(system("convert tmp/3p5zv1353677804.ps tmp/3p5zv1353677804.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.830 0.460 2.282