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(193590,193745,193885,194040,194190,194345,194495,194650,194805,194955,195110,195260,195415,195570,195710,195865,196015,196170,196320,196475,196630,196780,196935,197085,197240,197395,197540,197695,197845,198000,198150,198305,198460,198610,198765,198915,199070,199225,199365,199520,199670,199825,199975,200130,200285,200435,200590,200740,200895,201050,201190,201345,201495,201650,201800,201955,202110,202260,202415,202565,202720,202875,203015,203170,203320,203475,203625,203780,203935,204085,204240,204390,204545,204700,204845,205000,205150,205305,205455,205610,205765,205915,206070,206220,206375,206530,206670,206825,206975,207130,207280,207435,207590,207740,207895,208045,208200,208355,208495,208650,208800,208955,209105,209260,209415,209565,209720,209870) > 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/1aupo1439766148.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/2q1bc1439766148.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/3dhzp1439766148.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.972238171 0.944488605 0.916726322 0.888994471 [6] 0.861302683 0.833677340 0.806094700 0.778597608 0.751179172 [11] 0.723848849 0.696582016 0.669422124 0.642394843 0.615493938 [16] 0.588694480 0.562039608 0.535538944 0.509218900 0.483055670 [21] 0.457092165 0.431321458 0.405753020 0.380362236 0.355192505 [26] 0.330269633 0.305587249 0.281137531 0.256946862 0.233024864 [31] 0.209397968 0.186042319 0.163000887 0.140266707 0.117849268 [36] 0.095741019 0.073968574 0.052557810 0.031502285 0.010777164 [41] -0.009574436 -0.029542912 -0.049101793 -0.068274994 -0.087019496 [46] -0.105342282 -0.123233866 -0.140718838 -0.157753893 > (mypacf <- c(rpacf$acf)) [1] 0.97223817 -0.01385235 -0.01450313 -0.01392830 -0.01394829 -0.01366312 [7] -0.01428454 -0.01370739 -0.01401995 -0.01404390 -0.01469004 -0.01411143 [13] -0.01383669 -0.01413798 -0.01478920 -0.01421492 -0.01423163 -0.01394252 [19] -0.01456021 -0.01397585 -0.01427976 -0.01429567 -0.01493265 -0.01434454 [25] -0.01405188 -0.01434091 -0.01466287 -0.01436688 -0.01436160 -0.01404862 [31] -0.01464178 -0.01402846 -0.01430170 -0.01428544 -0.01457525 -0.01424622 [37] -0.01390975 -0.01415562 -0.01474398 -0.01410412 -0.01404529 -0.01367465 [43] -0.01420866 -0.01353012 -0.01373405 -0.01364590 -0.01417325 -0.01347056 > 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/4g6131439766148.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/5xyn41439766148.tab") > > try(system("convert tmp/1aupo1439766148.ps tmp/1aupo1439766148.png",intern=TRUE)) character(0) > try(system("convert tmp/2q1bc1439766148.ps tmp/2q1bc1439766148.png",intern=TRUE)) character(0) > try(system("convert tmp/3dhzp1439766148.ps tmp/3dhzp1439766148.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.189 0.245 1.439