R version 3.1.0 beta (2014-03-28 r65330) -- "Spring Dance" Copyright (C) 2014 The R Foundation for Statistical Computing Platform: i686-pc-linux-gnu (32-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(55.64,56.13,56.69,56.8,56.93,57,57.01,57.21,57.17,57.36,57.29,57.26,57.29,57.68,58.19,58.34,58.46,58.67,58.72,58.74,58.77,58.84,59.13,59.12,59.12,59.33,59.49,59.67,59.7,59.73,59.74,59.62,59.6,59.98,60.05,60.06,60.1,60.18,60.38,60.52,60.78,60.72,60.72,60.86,60.99,61.11,61.17,61.19,61.19,61.22,61.19,60.82,60.6,60.15,60.14,60.2,60.36,60.38,60.44,60.47) > 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/15i911397585362.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/2w0vv1397585362.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/31q4l1397585362.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.4275463538 0.1570017587 0.0150171261 0.0112075050 [6] 0.0688231096 0.0128882709 0.0239447041 -0.0173974389 -0.1204788793 [11] -0.0375436777 0.1497020592 0.2435851753 0.1006408795 -0.0843405388 [16] -0.0504819280 0.0209877226 -0.0685459886 -0.0436723451 0.0144482944 [21] 0.0802413922 0.0788629177 0.0170450531 0.0827751427 0.0841321928 [26] 0.0259726804 -0.0006061601 -0.0751032102 -0.1075786475 -0.0745042463 [31] -0.0518930813 0.0625084079 0.0459895512 -0.0226739103 -0.0705281916 [36] -0.0630312362 -0.0457747976 -0.1150179344 -0.1067183517 -0.1543079986 [41] -0.1243743131 0.0463002711 0.0784373043 0.0769221505 -0.0489779464 [46] -0.0122597334 -0.0674724014 -0.0151630553 -0.0564247417 > (mypacf <- c(rpacf$acf)) [1] 0.427546354 -0.031563872 -0.049892979 0.033695662 0.073477936 [6] -0.059214730 0.035953158 -0.035263226 -0.130401867 0.079439962 [11] 0.203463223 0.108643258 -0.099814542 -0.123416578 0.060167398 [16] 0.050732718 -0.163832661 0.010330843 0.092706192 0.111964112 [21] 0.059553188 -0.075685655 -0.012162330 0.023191973 0.032646932 [26] -0.005817517 -0.152828292 -0.078831401 0.151357955 0.044937884 [31] -0.025890688 -0.098283785 -0.024201450 0.010792280 -0.007219647 [36] -0.128275092 -0.169861625 0.080310031 0.018364980 0.008752959 [41] 0.094605007 -0.047493123 0.013685238 -0.096291322 0.062189386 [46] -0.151921238 0.028694988 0.009731120 > 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/4h78n1397585362.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/5y2kj1397585362.tab") > > try(system("convert tmp/15i911397585362.ps tmp/15i911397585362.png",intern=TRUE)) character(0) > try(system("convert tmp/2w0vv1397585362.ps tmp/2w0vv1397585362.png",intern=TRUE)) character(0) > try(system("convert tmp/31q4l1397585362.ps tmp/31q4l1397585362.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.772 0.332 2.115