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(2048,2037,2149,2124,2205,2489,2573,2702,2718,2646,2712,2634,2614,2637,2649,2579,2505,2462,2467,2447,2656,2626,2483,2540,2503,2467,2513,2443,2293,2071,2030,2052,1864,1670,1811,1905,1863,2014,2198,2962,3047,3033,3504,3801,3858,3674,3721,3844,4117,4105,4435,4296,4203,4563,4621,4697,4591,4357,4503,4444,4291,4200,4139,3970,3862,3702,3570,3801,3896,3918,3813,3667) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/1wa1k1354184865.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/2mq921354184865.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/3mief1354184865.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.969622135 0.928526058 0.886491350 0.836008322 [6] 0.780819039 0.723885358 0.667979283 0.614783407 0.556594962 [11] 0.496707533 0.443298070 0.384101969 0.325777566 0.270259179 [16] 0.214438380 0.157108186 0.095847909 0.041327187 -0.006157373 [21] -0.054361936 -0.095211060 -0.130614464 -0.158478143 -0.178971585 [26] -0.193326862 -0.203848798 -0.207066323 -0.210114242 -0.215250325 [31] -0.223453045 -0.230939485 -0.235114798 -0.243666012 -0.252597985 [36] -0.261390419 -0.270406178 -0.281933840 -0.293366908 -0.302713297 [41] -0.299282139 -0.296538951 -0.295610952 -0.288351287 -0.280125127 [46] -0.273050641 -0.271024619 -0.268365952 -0.264375147 > (mypacf <- c(rpacf$acf)) [1] 0.9696221346 -0.1945588908 -0.0059861173 -0.1691436601 -0.0605871482 [6] -0.0482006882 0.0089008053 0.0182708033 -0.1293771668 -0.0411697200 [11] 0.0607177254 -0.1633597854 0.0321381925 -0.0355958406 -0.0420784924 [16] -0.0847033430 -0.1133257884 0.1035280812 0.0028459460 -0.0505644179 [21] 0.0950067848 -0.0719920180 0.1069662468 0.0180395900 0.0573141334 [26] -0.0236290108 0.0279076635 -0.0238369041 -0.1082312325 -0.1152350388 [31] 0.0548994606 -0.0176964217 -0.0913663968 -0.0407831104 -0.0609580515 [36] -0.0265530927 -0.0879962133 0.0007659962 -0.0056888527 0.1939560574 [41] -0.0630943416 -0.0308174930 0.0506748386 0.0207457226 0.0317737655 [46] -0.1344676914 0.0408377424 -0.0241564933 > 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/4zgss1354184865.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/54wjn1354184865.tab") > > try(system("convert tmp/1wa1k1354184865.ps tmp/1wa1k1354184865.png",intern=TRUE)) character(0) > try(system("convert tmp/2mq921354184865.ps tmp/2mq921354184865.png",intern=TRUE)) character(0) > try(system("convert tmp/3mief1354184865.ps tmp/3mief1354184865.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.763 0.486 2.237