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(12849,11380,12079,11366,11328,10444,10854,10434,10137,10992,10906,12367,14371,11695,11546,10922,10670,10254,10573,10239,10253,11176,10719,11817,12487,11519,12025,10976,11276,10657,11141,10423,10640,11426,10948,12540,12200,10644,12044,11338,11292,10612,10995,10686,10635,11285,11475,12535,12490,12511,12799,11876,11602,11062,11055,10855,10704,11510,11663,12686,13516,12539,13811,12354,11441,10814,11261,10788,10326,11490,11029,11876) > 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/13emv1413624029.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/22suk1413624029.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/3q7kp1413624029.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.290062433 0.111011456 0.095265793 -0.224953058 [6] -0.043756524 -0.194680128 -0.018241396 -0.251612559 0.125718705 [11] 0.056038687 -0.176308868 0.573446157 -0.190461627 0.194072037 [16] 0.045374771 -0.155932643 0.010471691 -0.157089507 -0.021699568 [21] -0.173747105 0.064631832 0.013260801 -0.087601496 0.460257483 [26] -0.285204342 0.183631040 0.088137258 -0.105545415 -0.016274942 [31] -0.122202678 0.015502669 -0.167452232 0.029946419 0.023233229 [36] -0.087871144 0.328173460 -0.109877007 0.151567883 0.038217152 [41] -0.090648698 -0.009400620 -0.111804267 0.003611873 -0.157032911 [46] 0.036611798 -0.030339924 -0.026945653 0.237377429 > (mypacf <- c(rpacf$acf)) [1] -0.2900624333 0.0293441456 0.1475647006 -0.1818525360 -0.2003012889 [6] -0.2735986127 -0.1055160966 -0.3473257094 -0.1271621437 -0.0354907446 [11] -0.3399089721 0.2937207604 -0.0135304714 0.0800673109 0.0024296400 [16] -0.0611860439 0.0229696638 0.0308886816 -0.0182750069 0.0541373816 [21] -0.0310614273 0.0001495444 0.0011142645 0.2329400300 -0.1204346381 [26] -0.1174706373 0.0669535078 0.1211562818 -0.0591305879 -0.0795212875 [31] 0.0188481417 0.0152180491 -0.1460280788 -0.0048923762 0.0005478231 [36] -0.0628603246 0.1060224881 0.0872774297 0.0535755410 -0.1007361414 [41] -0.0782704166 0.0666421436 0.0504474205 -0.0827834434 0.0240114298 [46] -0.0851820239 -0.0118258188 -0.0146827986 > 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/4drbv1413624029.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/51o011413624029.tab") > > try(system("convert tmp/13emv1413624029.ps tmp/13emv1413624029.png",intern=TRUE)) character(0) > try(system("convert tmp/22suk1413624029.ps tmp/22suk1413624029.png",intern=TRUE)) character(0) > try(system("convert tmp/3q7kp1413624029.ps tmp/3q7kp1413624029.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.205 0.119 1.341