R version 3.0.3 (2014-03-06) -- "Warm Puppy" Copyright (C) 2014 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(3200944,3153170,3741498,3918719,4403449,4400407,4847473,4716136,4297440,4272253,3271834,3168388,2911748,2720999,3199918,3672623,3892013,3850845,4532467,4484739,4014972,3983758,3158459,3100569,2935404,2855719,3465611,3006985,4095110,4104793,4730788,4642726,4246919,4308032,3508154,3236641,3257275,3045631,3657692,4125747,4472507,4513455,5150896,5057815,4681742,4603682,3580181,3534002,3422762,3295209,3868093,4189245,4544332,4612845,5221595,5137505,4760439,4643697,3692267,3587603) > 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/wessaorg/rcomp/tmp/1y1sm1394716585.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/2vcrm1394716585.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/3mwrp1394716585.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.00000000 0.77330770 0.50893268 0.13467187 -0.26647374 -0.48730113 [7] -0.62275219 -0.50303725 -0.29611709 0.06019541 0.39824084 0.58287263 [13] 0.71182403 0.55219121 0.33412527 0.03004361 -0.28026299 -0.45064562 [19] -0.56732103 -0.46211147 -0.30300900 -0.02910966 0.22008786 0.34753567 [25] 0.44896729 0.31748439 0.16167230 -0.05630733 -0.29818076 -0.41056880 [31] -0.46882238 -0.37924276 -0.24717414 -0.05692158 0.12613787 0.23187618 [37] 0.29715705 0.21422162 0.09577375 -0.04033364 -0.17977788 -0.25089724 [43] -0.28589766 -0.23962178 -0.15536594 -0.02546972 0.08568466 0.13444705 [49] 0.16867487 > (mypacf <- c(rpacf$acf)) [1] 0.773307703 -0.221575097 -0.457143945 -0.441670803 0.112729718 [6] -0.050675272 0.285694446 -0.015556215 0.397955110 0.078771195 [11] -0.062688366 0.113017302 -0.183833933 0.061684877 -0.004480674 [16] 0.068838804 -0.018784333 -0.136327995 -0.059335390 -0.105867818 [21] 0.066112140 -0.160008012 -0.035147655 0.022420070 -0.127595134 [26] -0.050381596 0.005896618 -0.068591310 -0.003509127 0.095329830 [31] -0.106206639 -0.009264518 -0.135303365 0.032578376 0.144524391 [36] -0.079548853 0.022981337 -0.070948848 0.171129686 0.025690642 [41] -0.040378577 -0.036480884 -0.065595837 0.064454632 0.001976359 [46] -0.037983368 -0.162277800 0.002177720 > 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/4r9k51394716585.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/5lu101394716585.tab") > > try(system("convert tmp/1y1sm1394716585.ps tmp/1y1sm1394716585.png",intern=TRUE)) character(0) > try(system("convert tmp/2vcrm1394716585.ps tmp/2vcrm1394716585.png",intern=TRUE)) character(0) > try(system("convert tmp/3mwrp1394716585.ps tmp/3mwrp1394716585.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.586 0.538 3.130