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(101.94,102.62,102.71,103.39,104.51,104.09,104.29,104.57,105.39,105.15,106.13,105.46,106.47,106.62,106.52,108.04,107.15,107.32,107.76,107.26,107.89,109.08,110.4,111.03,112.05,112.28,112.8,114.17,114.92,114.65,115.49,114.67,114.71,115.15,115.03,115.07,116.46,116.37,116.2,116.5,116.38,115.44,114.96,114.48,114.3,114.66,114.97,114.79,116.16,116.52,117.14,117.27,117.58,117.21,117.08,117.06,117.55,117.61,117.74,117.87,118.59,119.09,118.93,119.62,120.09,120.38,120.49,120.02,120.17,120.58,121.54,121.51,121.81,122.85,122.97,122.96,123.4,123.23,123.24,123.72,123.99,125.1,125.4,125.35,126.37,127.17,127.66,128.48,129.21,129.48,128.63,128.16,128.1,128.08,128.14,128.19) > 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/1gud11425419635.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/2ih1l1425419635.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/3cmu21425419635.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.0000000000 0.9636184727 0.9277725931 0.8904128279 0.8524108819 [6] 0.8166467430 0.7778642985 0.7362843414 0.6955094536 0.6577030458 [11] 0.6194672834 0.5842312574 0.5479853222 0.5143550767 0.4798819672 [16] 0.4447187760 0.4146612925 0.3821529265 0.3513198199 0.3204384601 [21] 0.2879617772 0.2574582133 0.2290582800 0.2036623578 0.1813440198 [26] 0.1603174534 0.1387573099 0.1197912070 0.1049282802 0.0917314958 [31] 0.0766461010 0.0638276627 0.0494270518 0.0360995251 0.0244248736 [36] 0.0115433390 -0.0007691912 -0.0091117235 -0.0182841826 -0.0283203748 [41] -0.0376664727 -0.0467555565 -0.0585564092 -0.0723910465 -0.0887466883 [46] -0.1051463303 -0.1207876128 -0.1351256961 -0.1494497271 > (mypacf <- c(rpacf$acf)) [1] 0.9636184727 -0.0110298699 -0.0397350737 -0.0290812924 0.0111654438 [6] -0.0612109372 -0.0630422832 -0.0121486385 0.0213720604 -0.0306253037 [11] 0.0157730755 -0.0323217682 0.0152561219 -0.0387554180 -0.0349029620 [16] 0.0452736549 -0.0532883733 -0.0059801991 -0.0228841513 -0.0413575060 [21] -0.0001166690 0.0015072259 0.0232983146 0.0209386499 -0.0039143705 [26] -0.0223142288 0.0073200344 0.0420042162 -0.0023073851 -0.0502268672 [31] 0.0241378595 -0.0391586902 -0.0015111999 0.0003134384 -0.0282670614 [36] -0.0027900106 0.0414378226 -0.0207703987 -0.0255776354 -0.0087914433 [41] -0.0048905304 -0.0631369238 -0.0439093143 -0.0485158103 -0.0160686610 [46] -0.0026369288 -0.0053981668 -0.0090938466 > 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/4bihx1425419635.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/5lffz1425419635.tab") > > try(system("convert tmp/1gud11425419635.ps tmp/1gud11425419635.png",intern=TRUE)) character(0) > try(system("convert tmp/2ih1l1425419635.ps tmp/2ih1l1425419635.png",intern=TRUE)) character(0) > try(system("convert tmp/3cmu21425419635.ps tmp/3cmu21425419635.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.289 0.248 1.547