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(1.33,1.32,1.32,1.4,1.43,1.43,1.45,1.45,1.33,1.27,1.27,1.29,1.25,1.26,1.32,1.36,1.4,1.41,1.42,1.39,1.38,1.41,1.47,1.44,1.47,1.45,1.47,1.49,1.54,1.61,1.63,1.55,1.53,1.41,1.26,1.19,1.17,1.21,1.24,1.26,1.32,1.39,1.35,1.41,1.37,1.32,1.38,1.38,1.41,1.4,1.45,1.49,1.51,1.48,1.47,1.46,1.46,1.45,1.47,1.53,1.55,1.55,1.6,1.65,1.68,1.63,1.62,1.63,1.66,1.63,1.6,1.6) > 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/1zbz21352741162.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/22prg1352741162.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/3mc591352741162.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.368955609 0.113743988 0.027200900 -0.111181524 [6] -0.296797702 -0.351478282 -0.228115026 -0.005022119 -0.056796451 [11] 0.013646075 0.239606607 0.042239922 0.006261670 -0.005462455 [16] -0.058936121 -0.096381980 -0.161606153 -0.117831582 -0.048200101 [21] -0.140584649 0.034579321 0.173082096 0.145890172 0.105538066 [26] 0.167985998 0.167915827 -0.009145750 -0.203673776 -0.206553641 [31] -0.113942533 -0.151320805 -0.048233691 -0.007066052 0.110359191 [36] 0.086170067 0.134386079 0.108825901 -0.002029246 -0.051351131 [41] -0.009275893 -0.050767325 -0.061670749 -0.030274279 0.013760986 [46] 0.068407432 0.063538574 0.045779884 0.042446219 > (mypacf <- c(rpacf$acf)) [1] 0.368955609 -0.025911547 -0.007289295 -0.134549708 -0.247101046 [6] -0.196283503 -0.042126628 0.129393590 -0.132261969 -0.033493463 [11] 0.151581211 -0.232049814 0.011664831 -0.019593792 -0.081457255 [16] -0.039022710 -0.092802177 -0.065346330 -0.118379069 -0.141906286 [21] 0.088698877 0.001296367 0.042851629 -0.070608408 0.074331508 [26] 0.081517086 -0.124343046 -0.097777452 -0.132417118 0.020483698 [31] 0.012819976 -0.017302445 -0.150367871 -0.030549946 -0.036774582 [36] 0.065999614 -0.036781760 -0.097589872 -0.000490616 0.046379566 [41] -0.020913277 -0.006272821 -0.046311098 -0.004761367 0.039832216 [46] 0.076375637 -0.132963099 -0.112706441 > 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/4o9bl1352741162.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/5ajtp1352741162.tab") > > try(system("convert tmp/1zbz21352741162.ps tmp/1zbz21352741162.png",intern=TRUE)) character(0) > try(system("convert tmp/22prg1352741162.ps tmp/22prg1352741162.png",intern=TRUE)) character(0) > try(system("convert tmp/3mc591352741162.ps tmp/3mc591352741162.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.729 0.418 2.134