R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing Platform: x86_64-pc-linux-gnu (64-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(13396,13637,15467,13722,14727,14961,14026,13895,14474,15759,15995,14119,15342,15796,15435,16195,15572,16223,15921,14143,16290,16579,14314,13318,11938,12574,13298,12124,11757,12803,12800,11293,12992,13426,13174,13648,12801,13183,15703,14859,14350,16444,14207,13329,14795,15248,16081,15670,14805,15779,17945,15280,16773,16362,15774,15505,16397,16060,16748,16137,15523,16267,18066,16105,16883,17034,16452,16234,16658,18133,17488,15853,17198,16719,17635,16726,17503,17074,17054,15451,16374,17242,16684,16489) > 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/1zlmm1413740997.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/2x8v51413740997.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/3fe2w1413740997.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.3294549804 -0.2691462353 0.2018490587 -0.0240463019 [6] -0.0081197779 0.1177473000 -0.2150825259 0.2424344727 0.0363053342 [11] -0.3735880193 0.0192363469 0.4247550300 -0.1686361950 -0.1743315688 [16] 0.0199153556 0.0194506639 0.0014651592 0.0523749845 -0.1691977761 [21] 0.2426496680 -0.0150111815 -0.3137289753 0.0492599574 0.2735061179 [26] -0.1205940643 -0.0244907889 -0.1364202015 0.0983954955 0.0758921861 [31] -0.0995295237 0.0225348245 0.1295250656 -0.0768870382 -0.1209219003 [36] -0.0013976100 0.1581257027 0.0982278444 -0.2047170601 -0.0195037268 [41] 0.1038688029 -0.0552238943 0.0003283488 -0.0083934189 0.0837556012 [46] -0.0460487809 -0.0728244914 -0.0421441018 0.1661554950 > (mypacf <- c(rpacf$acf)) [1] -0.329454980 -0.423672478 -0.087458818 -0.104397557 0.015220869 [6] 0.149150126 -0.118441558 0.243863093 0.147870645 -0.216700152 [11] -0.352683034 0.158134981 0.153094013 -0.075572930 -0.155965898 [16] -0.099180712 -0.149899953 0.046937461 -0.034858125 0.062086221 [21] 0.010398871 -0.024475214 -0.125320804 -0.097984287 -0.077068756 [26] 0.024087059 -0.154709898 -0.015965827 -0.003634855 -0.021701504 [31] 0.113330348 -0.039383833 -0.070034748 -0.062705646 0.008940872 [36] -0.061811173 0.097431364 -0.124214197 -0.022062641 -0.056548448 [41] -0.101427699 -0.074843122 -0.103488738 0.015812636 -0.072222211 [46] 0.047142645 0.002408284 0.008615891 > 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/4d3mk1413740997.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/5kn3l1413740997.tab") > > try(system("convert tmp/1zlmm1413740997.ps tmp/1zlmm1413740997.png",intern=TRUE)) character(0) > try(system("convert tmp/2x8v51413740997.ps tmp/2x8v51413740997.png",intern=TRUE)) character(0) > try(system("convert tmp/3fe2w1413740997.ps tmp/3fe2w1413740997.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.189 0.172 1.371