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(3844.49,3720.98,3674.4,3857.62,3801.06,3504.37,3032.6,3047.03,2962.34,2197.82,2014.45,1862.83,1905.41,1810.99,1670.07,1864.44,2052.02,2029.6,2070.83,2293.41,2443.27,2513.17,2466.92,2502.66,2539.91,2482.6,2626.15,2656.32,2446.66,2467.38,2462.32,2504.58,2579.39,2649.24,2636.87,2613.94,2634.01,2711.94,2646.43,2717.79,2701.54,2572.98,2488.92,2204.91,2123.99,2149.1,2036.71,2048.32,2159.56,2267.79,2313.55,2247.3,2134.43,2114,2236.94,2345.39,2422.4,2385.96,2378.17,2457.13,2527.67,2530.03,2604.92,2596.8,2713.2,2574.82,2611.98,2768.46,2785.61,2859.27,2880.53,2824.5) > 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/16lgg1413815285.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/2f2831413815285.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/37wto1413815285.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.306206425 0.035464717 0.245244666 0.275447788 [6] 0.180514007 -0.175567758 -0.079925555 0.099388990 -0.097192110 [11] -0.217459695 -0.132023755 -0.059074691 -0.033602878 -0.086180005 [16] -0.066298643 0.020109391 -0.069778921 -0.020598260 0.075473964 [21] -0.083335979 -0.069244753 -0.005287498 -0.052594442 -0.072111247 [26] -0.096772279 -0.126098288 -0.080751208 -0.063385828 0.090951102 [31] 0.043098365 -0.033921897 0.084711877 0.102911742 0.156752997 [36] 0.111437447 0.047968850 0.161674634 0.064233517 -0.061203473 [41] -0.016145639 0.014320925 0.016613576 0.031312718 -0.015834519 [46] -0.055869521 -0.018115553 0.002983963 -0.005810667 > (mypacf <- c(rpacf$acf)) [1] 0.306206425 -0.064329328 0.280762497 0.133094025 0.098093076 [6] -0.345670217 -0.007608109 -0.006309003 -0.082077840 -0.083127015 [11] 0.021813475 -0.068152568 0.062899131 0.050426500 0.003000442 [16] -0.026455286 -0.115871639 0.033160269 0.066663420 -0.144635723 [21] -0.021342618 -0.005975080 -0.089356349 -0.025215767 0.047666750 [26] -0.172561487 -0.053118056 0.059756950 0.248982754 -0.041328916 [31] 0.010099681 -0.036184219 -0.032803454 0.097031094 0.111685586 [36] -0.043387607 -0.032301845 -0.110868839 -0.007047397 0.025040228 [41] 0.032488642 0.017906887 0.146747035 -0.010226629 -0.070533602 [46] 0.002230875 -0.031512841 -0.111756681 > 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/44a8n1413815285.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/5eu0s1413815285.tab") > > try(system("convert tmp/16lgg1413815285.ps tmp/16lgg1413815285.png",intern=TRUE)) character(0) > try(system("convert tmp/2f2831413815285.ps tmp/2f2831413815285.png",intern=TRUE)) character(0) > try(system("convert tmp/37wto1413815285.ps tmp/37wto1413815285.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.209 0.205 1.422