R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 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(38,35,33,35,33,32,33,38,45,42,40,44,50,37,37,35,33,40,38,39,52,48,49,50,48,45,42,39,38,44,47,45,51,51,47,49,44,40,40,38,36,45,39,43,50,49,47,49,58,43,39,44,45,57,54,52,61,59,60,58,52,49,60,51,52,56,56,57,58,100,70,70) > 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/wessaorg/rcomp/tmp/1dwi41363455151.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/2kxwp1363455151.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/33mmu1363455151.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.3643983333 -0.0813871622 0.0935684727 -0.0395358424 [6] -0.0368952915 -0.1124960914 0.0300539166 -0.1146772057 0.0593294951 [11] 0.0028902283 0.0300296727 0.0928818264 0.0852795637 -0.0686634704 [16] 0.0170639852 0.0501807686 -0.1391723249 0.0816505601 -0.1433805641 [21] -0.1912573557 0.3113075327 -0.0865714657 -0.0031958534 0.1149782128 [26] 0.0380564714 -0.0215858420 -0.0569530970 0.0785792124 -0.1091502895 [31] -0.0304846691 -0.0208705559 -0.0518493847 0.0582540128 0.0396743794 [36] -0.0856965956 0.1527525039 0.0410354611 -0.1044585916 0.0519786415 [41] 0.0021976765 -0.0578008813 -0.0028617661 -0.0876271887 -0.0004432296 [46] 0.0761069928 0.0032584171 0.0046789098 -0.0107764919 > (mypacf <- c(rpacf$acf)) [1] -0.364398333 -0.246967119 -0.041025231 -0.040147198 -0.060324509 [6] -0.199391749 -0.144262686 -0.263603344 -0.156951769 -0.154491995 [11] -0.092648193 0.002952843 0.140543004 0.034324039 0.043416759 [16] 0.087757022 -0.023410262 0.126943484 -0.023522715 -0.309861800 [21] 0.077483344 0.012506309 0.023142416 0.111492181 0.060408022 [26] 0.021491826 -0.036712643 -0.012882796 -0.016642069 -0.001332808 [31] -0.012291172 -0.007764959 0.029985070 -0.021294072 -0.121195321 [36] 0.027243748 -0.004929454 -0.059973172 -0.119681975 -0.050468985 [41] 0.062525817 0.043848319 -0.069751845 -0.055452949 0.015365769 [46] -0.024298691 0.001241227 -0.027084382 > 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/4utlf1363455151.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/5fk9o1363455151.tab") > > try(system("convert tmp/1dwi41363455151.ps tmp/1dwi41363455151.png",intern=TRUE)) character(0) > try(system("convert tmp/2kxwp1363455151.ps tmp/2kxwp1363455151.png",intern=TRUE)) character(0) > try(system("convert tmp/33mmu1363455151.ps tmp/33mmu1363455151.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.773 0.305 2.071