R version 3.0.1 (2013-05-16) -- "Good Sport" Copyright (C) 2013 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(865911,858030,850038,833499,997113,988455,865911,784437,792318,792318,801087,816849,865911,850038,874569,914862,1144188,1144188,1095237,1046175,1086468,1135530,1144188,1168719,1242312,1193250,1193250,1266843,1470861,1487400,1446330,1348206,1421799,1421799,1429680,1470861,1503273,1519812,1519812,1568874,1757130,1806081,1813962,1691418,1757130,1732599,1683537,1789542,1813962,1772892,1781550,1838493,2051280,2157174,2157174,2108223,2181705,2108223,2067042,2222886,2247306,2189586,2336661,2394381,2565987,2679873,2664111,2655342,2721054,2713062,2615049,2762124,2811186,2762124,2966142,3064266,3292704,3382836,3358416,3309354,3350424,3399486,3235761,3366297,3448548,3415359,3628035,3701517,4012317,4069260,3995778,4036848,4061379,4085910,3930066,4077141,4158615,4077141,4314459,4387941,4706622,4755684,4771446,4853697,4853697,4886109,4739034,4812627,4861578,4771446,5033184,5082246,5408808,5466528,5548002,5621595,5629476,5638134,5491059,5638134) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1bqh71377067723.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/2n56k1377067723.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/3e4mv1377067723.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.974719155 0.950395419 0.923516100 0.895875193 [6] 0.869072108 0.842311477 0.816446387 0.789800347 0.766717312 [11] 0.743586268 0.722907347 0.700637853 0.675179239 0.649834153 [16] 0.622247232 0.594465277 0.567805721 0.541511566 0.515622687 [21] 0.489258669 0.466547953 0.444629908 0.425049838 0.404081313 [26] 0.381287812 0.359169051 0.334732527 0.310250547 0.286982448 [31] 0.263936952 0.240165678 0.215911565 0.195336166 0.175408227 [36] 0.157581060 0.139018319 0.119110536 0.100155591 0.079028044 [41] 0.057995835 0.038273007 0.018141599 -0.001973126 -0.022262109 [46] -0.039939763 -0.056615707 -0.071657570 -0.087163235 -0.103813916 [51] -0.119634800 -0.136567528 -0.153920888 -0.169468537 -0.184434947 [56] -0.199431707 -0.213685418 -0.225838195 -0.237558097 -0.248249710 [61] -0.259059870 > (mypacf <- c(rpacf$acf)) [1] 9.747192e-01 6.369630e-03 -6.331050e-02 -3.120080e-02 4.161356e-03 [6] -1.118710e-02 2.064321e-03 -3.006293e-02 5.481389e-02 -1.043046e-02 [11] 3.025837e-02 -4.570852e-02 -8.095506e-02 -1.400598e-02 -4.948561e-02 [16] -2.328482e-02 1.297033e-02 -8.737381e-03 -6.112320e-03 -3.035167e-02 [21] 4.835969e-02 2.173225e-03 1.736373e-02 -4.315686e-02 -5.301160e-02 [26] -7.748055e-05 -4.698607e-02 -2.506225e-02 1.652265e-02 -1.139402e-02 [31] -2.633811e-02 -3.544039e-02 4.594456e-02 -2.610113e-03 4.286533e-03 [36] -3.219983e-02 -4.508350e-02 5.674713e-03 -4.436160e-02 -2.829133e-02 [41] 1.854318e-02 -2.286442e-02 -8.311573e-03 -2.998434e-02 2.161966e-02 [46] 3.953671e-03 -9.772569e-03 -3.004943e-02 -4.205745e-02 1.120691e-03 [51] -2.223947e-02 -4.389839e-02 2.688497e-02 2.117081e-03 -1.062430e-02 [56] -1.323021e-02 1.164358e-02 -7.900491e-03 -2.242787e-02 -2.541127e-02 > 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/475gd1377067723.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/51ssf1377067723.tab") > > try(system("convert tmp/1bqh71377067723.ps tmp/1bqh71377067723.png",intern=TRUE)) character(0) > try(system("convert tmp/2n56k1377067723.ps tmp/2n56k1377067723.png",intern=TRUE)) character(0) > try(system("convert tmp/3e4mv1377067723.ps tmp/3e4mv1377067723.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.368 0.569 2.912