R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing 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(96.86,96.77,96.5,96.01,96.07,95.93,95.93,95.83,96.24,96.25,96.59,96.62,96.62,96.81,96.71,96.45,96.63,96.56,96.56,96.65,97.04,97.14,97.2,97.26,97.26,97.24,97.35,97.36,97.28,97.31,97.31,97.31,97.23,97.78,97.64,97.68,97.68,97.81,97.75,97.63,97.6,97.65,97.65,97.65,97.86,98.41,98.79,98.75,98.74,98.55,98.65,98.86,98.94,99.05,99.05,99.05,99.17,98.99,98.91,98.89,98.89,98.72,98.89,98.97,99.16,99.54,99.54,99.55,100.01,99.52,99.44,99.39,99.39,99.4,100.43,100.62,101.05,100.95,100.95,100.91,101.13,100.81,100.47,100.56) > 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/1ghpo1385137247.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/2cxqk1385137247.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/3z67s1385137247.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.073380412 0.115018957 -0.054792033 -0.062780190 [6] -0.328024738 0.001527826 -0.274250548 -0.049098821 0.084281545 [11] 0.080102412 0.039730091 0.248411438 0.013309452 -0.074718810 [16] -0.048894018 -0.141642979 -0.117867332 -0.066932756 -0.058881655 [21] 0.077470059 0.035723940 0.046372887 0.116047815 -0.016035907 [26] 0.038932613 -0.063185207 -0.025063201 0.002853439 0.148862695 [31] 0.004082518 -0.005187013 0.042640209 0.028800902 -0.020958120 [36] 0.070375276 -0.135494943 -0.025711925 -0.020837789 -0.018317567 [41] -0.068438977 0.065454406 -0.031720135 0.020410994 -0.044227585 [46] 0.017866440 0.005334538 0.012283558 -0.037806263 > (mypacf <- c(rpacf$acf)) [1] 0.073380412 0.110227814 -0.071641940 -0.068266046 -0.312803228 [6] 0.057106766 -0.242903046 -0.061544421 0.113885154 -0.053285231 [11] 0.019849380 0.112139883 -0.021455728 -0.113597137 -0.048154099 [16] -0.071281615 0.002587766 -0.093321070 -0.033568714 0.105443048 [21] -0.144896904 -0.017296155 0.080864183 -0.148269116 0.093323852 [26] -0.094127722 0.039484255 0.123003410 0.079365120 0.098301640 [31] -0.106097968 0.024791132 0.093445539 0.002441008 0.086581999 [36] -0.083401546 0.022733945 0.009523267 -0.005235001 -0.064777016 [41] -0.010243570 -0.014597742 -0.001736909 -0.040274458 -0.026049920 [46] 0.121742318 -0.088596966 0.002717866 > 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/4e1031385137247.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/52i491385137247.tab") > > try(system("convert tmp/1ghpo1385137247.ps tmp/1ghpo1385137247.png",intern=TRUE)) character(0) > try(system("convert tmp/2cxqk1385137247.ps tmp/2cxqk1385137247.png",intern=TRUE)) character(0) > try(system("convert tmp/3z67s1385137247.ps tmp/3z67s1385137247.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.791 0.428 2.201