R version 2.12.0 (2010-10-15) Copyright (C) 2010 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(588264,577918,567562,546859,756344,745987,588264,483527,493873,493873,504229,526055,462824,399492,347630,347630,546859,567562,409838,231412,325803,325803,399492,442021,431664,325803,378790,357986,536412,493873,325803,200263,315447,347630,378790,420195,336150,263595,294755,305101,577918,577918,420195,399492,462824,431664,515709,620447,641250,493873,452367,409838,694135,714939,661953,714939,704481,620447,714939,819676,862205,735641,651596,714939,987746,1071790,1051088,1092483,1082137,977399,1155825,1198354,1260562,1071790,998102,1082137,1282389,1460814,1418286,1418286,1439089,1366423,1555307,1555307,1523124,1344597,1376780,1397583,1534503,1712929,1586355,1649698,1596712,1565653,1807421,1754435,1680746,1576009,1680746,1733732,1796963,1880998,1796963,1848826,1785585,1775239,2037699,2059525,1975491,1828123,1953664,2006549,2069882,2164273,2069882,2143570,2111388,1996193,2237951,2237951) > 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/www/rcomp/tmp/1aqyz1343739123.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/www/rcomp/tmp/2hdyp1343739123.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/www/rcomp/tmp/3dn9b1343739123.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.018818078 -0.301951862 -0.309554548 -0.140992511 [6] 0.190834368 0.300912016 0.175894212 -0.089058259 -0.332198447 [11] -0.286087873 0.065212271 0.798032513 0.003691003 -0.253091148 [16] -0.244860017 -0.117948111 0.127763527 0.273750555 0.152463252 [21] -0.087045798 -0.325781717 -0.188679050 0.079851151 0.605595490 [26] -0.041288787 -0.189745600 -0.144888644 -0.140571318 0.033676441 [31] 0.280725232 0.155509262 -0.050021858 -0.330090877 -0.180605004 [36] 0.077279674 0.424387610 -0.026096772 -0.115719608 -0.068793397 [41] -0.163472708 -0.056719750 0.274980686 0.183470610 -0.016885473 [46] -0.316522301 -0.159941028 0.038161308 0.317646910 > (mypacf <- c(rpacf$acf)) [1] 0.018818078 -0.302413072 -0.326420584 -0.304045852 -0.070775636 [6] 0.095370985 0.211231481 0.185049492 -0.031133857 -0.240331937 [11] -0.235164039 0.676211630 -0.030314509 0.081387119 0.126620865 [16] 0.182846407 -0.102569975 0.015193572 -0.035659869 -0.122823066 [21] -0.095903598 0.175433289 -0.048514981 -0.064561795 -0.054796049 [26] 0.100363760 0.054766038 -0.125405021 -0.166679864 0.074833863 [31] 0.059926270 0.106191619 -0.059264727 -0.134826375 -0.082749274 [36] -0.121372367 0.009597485 -0.133514898 -0.005238735 0.023997266 [41] 0.085497819 0.061591635 0.090508964 -0.034847553 -0.019566786 [46] 0.039174409 -0.023386467 -0.016663496 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/www/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/www/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/www/rcomp/tmp/45ui11343739123.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/www/rcomp/tmp/5ogrm1343739123.tab") > > try(system("convert tmp/1aqyz1343739123.ps tmp/1aqyz1343739123.png",intern=TRUE)) character(0) > try(system("convert tmp/2hdyp1343739123.ps tmp/2hdyp1343739123.png",intern=TRUE)) character(0) > try(system("convert tmp/3dn9b1343739123.ps tmp/3dn9b1343739123.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 0.850 0.640 1.467