R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" 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(9969,9692,8943,8802,8250,8515,13973,13905,12467,9490,8483,7610,7839,7107,6584,6053,5725,6480,11663,11628,9203,7781,7020,6908,6912,6668,6189,6007,5148,6685,11044,11034,8986,8146,7818,8176,8935,8929,8835,8455,7924,8973,13575,13844,11738,10467,10145,10833,10179,10107,9533,9165,8382,9018,13911,13761,11316,9855,9034,8932,9278,8876,8298,7733,7226,7688,12226,12081,10439,9008,8377,8346,9167,8945,8428,7973,7446,7785,10561,12791,11583,10112,9597,9332) > 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/1wg2j1384333061.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/2eov41384333061.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/34xbd1384333061.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.692409571 0.233343039 -0.022869338 -0.061472921 [6] 0.001503527 0.047081807 -0.023092171 -0.128175857 -0.148978443 [11] 0.024283633 0.387349654 0.627484950 0.374852321 -0.024111163 [16] -0.234278740 -0.268712300 -0.211020760 -0.176581096 -0.231890393 [21] -0.319145882 -0.331095532 -0.185801928 0.126087726 0.345906438 [26] 0.173216857 -0.129299049 -0.279597709 -0.278819784 -0.205200776 [31] -0.151562766 -0.174569735 -0.217843597 -0.205793870 -0.070511756 [36] 0.193538649 0.387878392 0.263168120 0.024336520 -0.099892308 [41] -0.112485411 -0.061907860 -0.028550518 -0.054384898 -0.100164992 [46] -0.097297232 0.003087340 0.188350987 0.324888205 0.223102554 [51] 0.035442898 -0.079973072 -0.106469065 -0.079516346 -0.052262511 [56] -0.081308654 -0.115654524 -0.115780679 -0.044522266 0.079173489 [61] 0.179276151 > (mypacf <- c(rpacf$acf)) [1] 0.6924095710 -0.4727288433 0.1645211259 -0.0021214749 0.0428403928 [6] -0.0209232532 -0.1629908256 0.0002542601 0.0181385403 0.2873503274 [11] 0.4481916150 0.0796097936 -0.6054160019 0.0866344033 -0.0103956310 [16] -0.2202429797 -0.0396728865 -0.1574421301 0.0263888213 -0.0339261216 [21] -0.0433033746 -0.0728277606 -0.0362205306 0.0238669124 -0.0218744769 [26] 0.0130388258 -0.0863896804 0.0712294305 -0.0238208738 0.0213046357 [31] 0.0109672360 0.0438416216 0.0243565045 0.0215302206 -0.0069069536 [36] 0.0174093881 0.0020069360 0.0096858817 -0.0312754094 -0.0908852965 [41] 0.0305947617 -0.0477333851 -0.0258972151 -0.0713186616 -0.0062142729 [46] 0.0012013565 -0.1614090902 0.0331407983 -0.0180379348 0.0270996151 [51] -0.1167268325 0.0645469499 -0.0310807151 0.0570953913 -0.0582013789 [56] 0.0510052242 -0.0378152088 -0.0478529353 0.0258963748 -0.0314223995 > 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/4s2c41384333061.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/5n1u11384333061.tab") > > try(system("convert tmp/1wg2j1384333061.ps tmp/1wg2j1384333061.png",intern=TRUE)) character(0) > try(system("convert tmp/2eov41384333061.ps tmp/2eov41384333061.png",intern=TRUE)) character(0) > try(system("convert tmp/34xbd1384333061.ps tmp/34xbd1384333061.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.843 0.378 2.200