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 = '0' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > 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/1bxy51413815020.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/2bj971413815020.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/3s01x1413815020.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.89153191 0.76074209 0.62990371 0.45929992 0.26499247 [7] 0.07940480 -0.04869456 -0.17291127 -0.29832435 -0.34965410 -0.36194119 [13] -0.34768134 -0.32938582 -0.29796423 -0.24569551 -0.20342022 -0.17743480 [19] -0.14055977 -0.10299210 -0.09249382 -0.08871111 -0.08550527 -0.07751140 [25] -0.06583338 -0.04872507 -0.01757814 0.01136371 0.04552921 0.10159301 [31] 0.14112734 0.17489070 0.20591655 0.22152635 0.22178060 0.20567901 [37] 0.18126755 0.15021249 0.09533511 0.03875304 -0.01700112 -0.06908974 [43] -0.11169180 -0.14958133 -0.16674765 -0.17949833 -0.18832298 -0.18342696 [49] -0.18103664 > (mypacf <- c(rpacf$acf)) [1] 0.891531914 -0.166139919 -0.064576409 -0.281535945 -0.216303096 [6] -0.115806535 0.166653112 -0.110543315 -0.149551427 0.141055963 [11] 0.006588530 0.071917184 -0.109434497 -0.120288309 -0.043445286 [16] 0.025156210 -0.087684137 0.011973104 -0.004302879 -0.123635646 [21] 0.041583080 -0.062561401 -0.010290571 0.055551135 0.038490787 [26] -0.016924885 -0.005663855 0.033978697 0.116109994 -0.042810633 [31] -0.038483247 0.011827481 -0.004788930 0.021222912 0.027858831 [36] -0.044327847 -0.003236389 -0.029812599 -0.017868863 -0.018163214 [41] 0.003496634 0.006773236 -0.011764909 0.011185174 -0.076130757 [46] 0.016244563 -0.022864359 -0.100632459 > 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/4xeam1413815020.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/5lwtp1413815020.tab") > > try(system("convert tmp/1bxy51413815020.ps tmp/1bxy51413815020.png",intern=TRUE)) character(0) > try(system("convert tmp/2bj971413815020.ps tmp/2bj971413815020.png",intern=TRUE)) character(0) > try(system("convert tmp/3s01x1413815020.ps tmp/3s01x1413815020.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.152 0.189 1.354