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(98.68,99.06,99.84,100.3,100.38,100.02,99.83,100.36,100.74,100.49,100.33,99.96,100.08,100.54,101.63,102.12,102.19,101.77,101.29,101.47,102.07,102.11,102.26,101.83,102.11,102.8,103.82,104.2,104.57,104.38,104.54,104.74,105.19,104.95,104.57,103.81,104.08,104.81,105.86,106.1,106.24,105.87,104.74,105.03,105.59,105.69,105.58,104.96,104.93,105.68,106.93,107.29,107.25,106.74,106.44,106.6,107.26,107.35,107.22,106.99,106.87,107.68,108.9,109.48,109.57,109.03,109.58,109.76,110.15,110.2,109.86,109.58,109.52,110.35,111.61,112.06,111.9,111.36,112.09,112.24,112.7,113.36,112.9,112.74,112.77,113.66,114.87,114.97,115,114.57,115.54,115.39,115.46,115.13,114.56,114.62) > 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/1mx3d1425590862.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/2kx1s1425590862.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/3l93q1425590862.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.964863414 0.926514112 0.889995853 0.858859657 [6] 0.830345305 0.796469711 0.759967382 0.721142034 0.686488385 [11] 0.655810030 0.629506259 0.600492478 0.563107485 0.523106405 [16] 0.486845094 0.458915862 0.434418807 0.405983501 0.373687258 [21] 0.338583102 0.308006189 0.283392954 0.263888161 0.241259536 [26] 0.212292725 0.181576454 0.154584603 0.132995081 0.115178941 [31] 0.094558111 0.072474003 0.048408494 0.029261829 0.014837074 [36] 0.003360469 -0.011740316 -0.031666540 -0.052614636 -0.069135507 [41] -0.081028639 -0.089427013 -0.100596230 -0.120471188 -0.141565969 [46] -0.158647249 -0.171562346 -0.180492363 -0.192149981 -0.207658337 [51] -0.224856040 -0.237300065 -0.246164532 -0.253388119 -0.262973069 [56] -0.280262784 -0.298685239 -0.312972999 -0.324253175 -0.332755083 [61] -0.342203815 > (mypacf <- c(rpacf$acf)) [1] 0.9648634143 -0.0644175389 0.0087813223 0.0564633655 0.0150382456 [6] -0.0935035730 -0.0433129865 -0.0500762458 0.0307536191 0.0220600807 [11] 0.0428381070 -0.0504210475 -0.1212410594 -0.0502325046 0.0196945015 [16] 0.0657345989 0.0171080340 -0.0557420134 -0.0411416791 -0.0516083896 [21] 0.0176176373 0.0293014226 0.0392979123 -0.0442636270 -0.0669219254 [26] -0.0283774973 0.0075151426 0.0006624607 0.0195774286 -0.0321312703 [31] 0.0086964840 -0.0321953499 0.0252573762 -0.0007298205 0.0032233414 [36] -0.0477876980 -0.0312440674 -0.0176484498 0.0208873873 -0.0087024124 [41] 0.0225902611 -0.0314936140 -0.1030541468 -0.0206853807 0.0101814777 [46] -0.0158696549 0.0242255278 -0.0212860797 -0.0231481269 -0.0356098665 [51] 0.0186454233 -0.0243853429 -0.0110141833 -0.0215540068 -0.0739762755 [56] -0.0268628058 0.0073875577 -0.0481799773 0.0023731518 0.0041766784 > 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/4v3e11425590862.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/5h2i61425590862.tab") > > try(system("convert tmp/1mx3d1425590862.ps tmp/1mx3d1425590862.png",intern=TRUE)) character(0) > try(system("convert tmp/2kx1s1425590862.ps tmp/2kx1s1425590862.png",intern=TRUE)) character(0) > try(system("convert tmp/3l93q1425590862.ps tmp/3l93q1425590862.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.235 0.236 1.479