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(25,24,25,27,24,26,24,24,21,23,24,23,22,25,26,22,24,22,23,25,24,24,21,22,21,21,20,20,22,21,23,22,24,21,22,20,23,21,21,21,22,24,21,23,25,23,24,25,28,26,25,24,25,26,24,21,22,25,27,26,24,27,23,23,23,25,26,22,23,27,25,24,21,24,22,26,22,25,20,21,23,24,24,18) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1l3v61384438462.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/2p1ju1384438462.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/3r2pp1384438462.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.341853638 0.274497737 0.139107085 0.323082921 [6] 0.240604214 0.048047212 0.143896059 0.080472803 0.135207639 [11] 0.052728932 0.174568984 0.109072151 -0.002400871 -0.085701858 [16] -0.078802280 0.127017608 -0.002474076 -0.042801984 -0.215266747 [21] -0.186523117 -0.191850488 -0.257240067 -0.234502657 -0.351981900 [26] -0.225172415 -0.304540757 -0.092714648 -0.112235291 -0.073660049 [31] -0.207191632 -0.228464090 -0.224782130 -0.156998064 -0.133331120 [36] -0.260749228 -0.183955832 -0.101156215 -0.030476293 -0.029904697 [41] -0.063296850 0.049426617 -0.096117407 0.064655826 0.060257988 [46] 0.177021354 0.081493418 0.110129794 0.117851652 0.050495752 [51] 0.091251824 0.018819236 0.095612633 0.009201282 0.096040797 [56] 0.115667843 0.196286630 0.086672676 0.037228184 0.062968704 [61] 0.012594677 > (mypacf <- c(rpacf$acf)) [1] 0.3418536375 0.1784932456 0.0011695076 0.2745504421 0.0746754839 [6] -0.1797381006 0.1438234104 -0.0446728837 -0.0074903887 0.0580217432 [11] 0.1283258912 -0.0326180773 -0.1159387896 -0.1221269667 -0.0915564035 [16] 0.1877039674 -0.0050500830 -0.0592944493 -0.1740885896 -0.2281587533 [21] -0.1319353140 -0.1177085082 -0.0288417340 -0.1145248808 0.0271599264 [26] -0.1047766417 0.0707974604 0.0565850990 0.0604869703 -0.0411928822 [31] -0.0376896854 -0.2101725239 -0.0081534722 -0.0077769888 -0.1135743392 [36] 0.0458957361 0.1141499025 -0.0557179962 0.0368371739 0.0070057879 [41] 0.0446143591 -0.1178338073 0.0807157297 -0.0510422830 -0.0495935805 [46] -0.0307842590 0.0893304827 -0.0120381339 -0.1010573601 -0.0547914110 [51] -0.0165499384 -0.0485294591 -0.0128194458 -0.0443975183 -0.0646114100 [56] -0.0205909670 -0.1681954944 -0.0895926014 -0.0009782958 -0.0874003467 > 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/47et81384438462.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/5ib151384438462.tab") > > try(system("convert tmp/1l3v61384438462.ps tmp/1l3v61384438462.png",intern=TRUE)) character(0) > try(system("convert tmp/2p1ju1384438462.ps tmp/2p1ju1384438462.png",intern=TRUE)) character(0) > try(system("convert tmp/3r2pp1384438462.ps tmp/3r2pp1384438462.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.806 0.396 2.185