R version 2.13.0 (2011-04-13) Copyright (C) 2011 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 = '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/16vaj1343737896.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/2a62p1343737896.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/35qk81343737896.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.96641554 0.93166391 0.91182674 0.89732020 0.88764225 [7] 0.87380022 0.84651891 0.81509372 0.78761176 0.77088199 0.76564574 [13] 0.75420900 0.71579949 0.67671500 0.65121989 0.63216789 0.61630140 [19] 0.59781343 0.56694950 0.53161163 0.50093050 0.48079600 0.46930911 [25] 0.45255317 0.41531836 0.37630578 0.34946647 0.32537163 0.30521799 [31] 0.28492425 0.25077383 0.21513512 0.18530084 0.16562225 0.15200006 [37] 0.13116686 0.09561202 0.05958765 0.03189734 0.00385420 -0.01664872 [43] -0.03590968 -0.06642906 -0.09818354 -0.12379634 -0.13844988 -0.14994879 [49] -0.16709151 > (mypacf <- c(rpacf$acf)) [1] 0.966415544 -0.034752501 0.208415535 0.063765605 0.117394339 [6] -0.037905170 -0.169764542 -0.089851195 -0.040233152 0.096082912 [11] 0.158376815 -0.025331269 -0.334451681 -0.030768184 0.064340704 [16] 0.019982721 -0.002383062 0.007744995 -0.062072161 -0.037212441 [21] -0.031931574 0.010410804 0.031309288 0.016602525 -0.133461094 [26] -0.049393776 0.018731266 -0.074220015 0.005434695 0.017239512 [31] -0.079187259 0.027799337 -0.018734637 0.026983810 -0.021643117 [36] -0.042848424 -0.054524727 -0.031963914 -0.030207012 -0.122957804 [41] 0.051234320 0.020082698 -0.002533689 0.005901467 -0.015459196 [46] 0.058251927 -0.040548587 -0.009777360 > 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/48bcd1343737896.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/5clvd1343737896.tab") > > try(system("convert tmp/16vaj1343737896.ps tmp/16vaj1343737896.png",intern=TRUE)) character(0) > try(system("convert tmp/2a62p1343737896.ps tmp/2a62p1343737896.png",intern=TRUE)) character(0) > try(system("convert tmp/35qk81343737896.ps tmp/35qk81343737896.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.232 0.259 1.488