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(8.09,8.18,8.26,8.28,8.28,8.28,8.29,8.3,8.3,8.31,8.33,8.33,8.34,8.48,8.59,8.67,8.67,8.67,8.71,8.72,8.72,8.72,8.74,8.74,8.74,8.74,8.79,8.85,8.86,8.87,8.92,8.96,8.97,8.99,8.98,8.98,9.01,9.01,9.03,9.05,9.05,9.05,9.13,9.13,9.13,9.14,9.16,9.16,9.16,9.16,9.22,9.22,9.25,9.25,9.26,9.26,9.29,9.28,9.37,9.41,9.41,9.45,9.49,9.49,9.56,9.54,9.55,9.55,9.57,9.57,9.58,9.59,9.59,9.59,9.61,9.61,9.62,9.62,9.63,9.65,9.65,9.68,9.73,9.73,9.73,9.74,9.68,9.68,9.74,9.74,9.76,9.78,9.79,9.81,9.84,9.84) > 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/1zxrr1425383178.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/2uhxh1425383178.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/33ft21425383178.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.2006010773 -0.0212005265 0.0008107081 -0.0378251313 [6] -0.1060433373 0.0202473508 -0.2388061220 -0.0126830029 -0.0770342329 [11] -0.1342960068 0.0193213118 0.3345782282 0.1562801047 0.1171931181 [16] -0.0678722134 0.1092047598 0.0654774019 -0.0094435625 -0.0750193349 [21] 0.0406371691 -0.1055650534 -0.1055955821 -0.0338292560 0.0428352397 [26] -0.0411086688 0.0294975645 -0.0627603425 0.0280186158 0.1473487470 [31] -0.0159326196 -0.0204746204 0.1207683749 -0.0821494959 -0.1003548120 [36] -0.0085446602 -0.0083818401 0.0503656667 -0.0110208817 -0.0680248572 [41] 0.0435713220 -0.0095656775 -0.0779127827 0.0452843245 0.0123844995 [46] 0.0692629679 0.0745817560 -0.0752940937 0.0564748104 > (mypacf <- c(rpacf$acf)) [1] 0.200601077 -0.064017431 0.019017876 -0.045272970 -0.092438883 [6] 0.061409564 -0.280363789 0.121157421 -0.161362434 -0.088144188 [11] 0.072144858 0.277494021 0.078806855 0.011294051 -0.091156809 [16] 0.181932108 -0.002242939 -0.013716928 0.058615589 0.044838921 [21] -0.018919198 -0.078665277 0.110987558 -0.073076559 -0.150635390 [26] 0.030729867 -0.006201602 -0.054653756 0.092701190 -0.121776570 [31] 0.085562316 -0.015451234 -0.090939554 -0.003772555 -0.031217064 [36] 0.061171591 0.064643023 -0.022060608 0.072798726 -0.040466784 [41] -0.074896167 -0.012315499 0.010857667 0.013478093 0.073233940 [46] 0.110475935 -0.051395414 0.053439696 > 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/4sutf1425383178.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/5hndz1425383178.tab") > > try(system("convert tmp/1zxrr1425383178.ps tmp/1zxrr1425383178.png",intern=TRUE)) character(0) > try(system("convert tmp/2uhxh1425383178.ps tmp/2uhxh1425383178.png",intern=TRUE)) character(0) > try(system("convert tmp/33ft21425383178.ps tmp/33ft21425383178.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.168 0.218 1.394