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(3477,2685,2438,1692,4054,3946,3623,2455,2362,2791,2369,3438,3682,2801,2563,3108,2890,3940,4036,1514,3461,2980,2728,3891,3715,2843,1416,2657,1856,2441,3172,2813,3335,2608,5784,4726,3817,2755,2541,3154,2684,3732,4286,2394,1698,3945,2549,3943,3899,2783,2660,1848,4482,4157,4404,2686,2593,3254,2664,4203,3985,2861,2758,1968,4666,4226,4748,2767,2723,3297,2758,4338) > 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/1g5731395094344.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/2dhhg1395094344.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/3mpnz1395094344.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.14880388 -0.09447774 -0.27784795 -0.21940342 0.14730336 [7] 0.16234558 0.27047446 -0.26316100 -0.31238824 -0.17432722 0.18701428 [13] 0.37294751 0.07937062 -0.05819534 -0.30983435 -0.13862781 0.14409727 [19] 0.37655259 0.21268528 -0.11512905 -0.20136575 -0.12668347 0.08286715 [25] 0.14767069 0.13312079 -0.17703136 -0.17735441 -0.13499506 0.08563043 [31] 0.37474783 0.01132012 -0.04363850 -0.24240232 -0.07276368 0.04816758 [37] 0.13640465 0.12118267 -0.19217972 -0.13718366 -0.12426200 0.12122716 [43] 0.11739603 0.02773797 -0.05229557 -0.19533588 -0.08504529 0.02238089 [49] 0.19980528 > (mypacf <- c(rpacf$acf)) [1] 0.1488038753 -0.1192610856 -0.2535052202 -0.1674986643 0.1665755548 [6] 0.0364735126 0.2023319321 -0.3264176100 -0.1478275317 -0.0685520141 [11] 0.2246587719 0.1200662603 -0.0545332313 -0.0521220204 -0.0237329096 [16] -0.0077479993 0.0727376444 0.1790228770 0.0564325138 0.0683666935 [21] 0.0271855144 0.0727822770 -0.0589866609 -0.0801324315 0.0062869376 [26] -0.0670068127 0.1418460843 -0.0546042676 -0.0394025990 0.2010826887 [31] -0.1445369106 -0.0179035702 -0.0593084835 0.0468269071 -0.0608408333 [36] -0.0209933766 -0.1225935503 -0.0176291876 -0.0702243588 0.0005377721 [41] -0.0710684344 -0.0691592722 0.0123403439 -0.0095047209 -0.0074813012 [46] -0.1201133472 -0.0772819532 0.0131702631 > 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/461xa1395094344.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/558tg1395094344.tab") > > try(system("convert tmp/1g5731395094344.ps tmp/1g5731395094344.png",intern=TRUE)) character(0) > try(system("convert tmp/2dhhg1395094344.ps tmp/2dhhg1395094344.png",intern=TRUE)) character(0) > try(system("convert tmp/3mpnz1395094344.ps tmp/3mpnz1395094344.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.958 0.782 3.628