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(181896,181580,181234,180598,187123,186807,181896,178638,178954,178954,179269,179936,181580,179616,181580,179936,185158,187469,177656,175025,177305,176989,175025,175345,179269,178638,179269,179269,183545,184176,172398,172398,176989,174709,170785,172398,176327,174363,174047,169803,176007,177305,164545,164229,170785,167176,160967,163598,166509,167176,165212,161287,169456,169456,155078,154101,158025,150838,143616,145932,150838,146910,144283,138710,146247,146563,132190,131839,134470,126301,117465,121043,125950,120728,120412,115154,123670,125319,109266,105688,107968,99132,89981,92928,98470,91946,92928,89004,97172,98150,78524,77221,80799,71333,62817,65764,72950,64462,63799,57244,64462,66742,46448,46448,49391,41542,32706,37297,45466,36631,40244,35333,43186,45813,24853,23240,26502,18649,12444,15040) > 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/15nqq1344979926.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/2ijgt1344979926.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/3mh461344979926.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.12101633 -0.53395911 0.22140430 0.32943628 -0.05985135 [7] -0.40754861 -0.04490286 0.32695071 0.18201307 -0.49356394 -0.08108663 [13] 0.86536779 -0.11779944 -0.50877266 0.21819230 0.31890105 -0.09247984 [19] -0.35770412 -0.02556375 0.29480391 0.13833107 -0.42661798 -0.05716038 [25] 0.73427934 -0.10700426 -0.45790092 0.21046114 0.27204645 -0.11867138 [31] -0.30998753 -0.01091328 0.24312772 0.09131839 -0.36313157 -0.04431740 [37] 0.60109783 -0.10322420 -0.39294433 0.19321800 0.23462937 -0.13119406 [43] -0.26398680 0.01265038 0.18514258 0.05592347 -0.30808804 -0.04656574 [49] 0.47758905 > (mypacf <- c(rpacf$acf)) [1] -0.121016331 -0.556757754 0.078588158 0.120745894 0.243783101 [6] -0.298244690 -0.254366056 -0.144809929 0.454984149 -0.239026041 [11] 0.055163317 0.675197092 0.124655567 0.124941962 -0.020249133 [16] -0.031330879 -0.098474523 0.129031239 0.030795600 -0.018811602 [21] -0.085833859 0.076272188 -0.040455509 0.013236203 -0.010787604 [26] 0.081894642 -0.013513335 -0.069596395 -0.088954497 -0.070498647 [31] -0.036655952 -0.047783984 -0.062443910 -0.074455059 -0.078765537 [36] -0.119161633 -0.068937695 -0.006518176 -0.010539378 0.047184266 [41] 0.005255138 -0.021903750 0.006997774 -0.026516255 0.021148886 [46] -0.032704213 -0.061996685 -0.115875568 > 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/4xncr1344979926.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/5klel1344979926.tab") > > try(system("convert tmp/15nqq1344979926.ps tmp/15nqq1344979926.png",intern=TRUE)) character(0) > try(system("convert tmp/2ijgt1344979926.ps tmp/2ijgt1344979926.png",intern=TRUE)) character(0) > try(system("convert tmp/3mh461344979926.ps tmp/3mh461344979926.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.424 0.354 1.765