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(246.78,247.91,247.99,248.6,248.68,248.75,248.75,249.03,249.05,249.57,249.35,249.46,249.46,250.82,254.19,255.18,256.68,256.73,256.73,257.39,257.78,258.67,258.71,258.91,258.91,261.38,262.42,262.77,263.24,262.83,262.83,263.09,263.6,265.68,266.08,266.28,266.28,269.14,270.96,272.97,273.13,274.73,274.73,274.59,275.15,275.16,275.38,275.4,275.4,275.71,275.21,279.04,279.1,279.11,279.11,279.02,279.3,279.34,279.36,279.39,279.39,280.21,283,284.33,285.15,284.21,284.21,284.17,286.28,286.95,287.12,287.34) > 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/1z4ps1413534199.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/2smhu1413534199.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/3izeg1413534199.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.96100753 0.92175995 0.88081768 0.84150597 0.80475826 [7] 0.76617813 0.72563421 0.68211103 0.63890075 0.59819015 0.56030574 [13] 0.52150854 0.47966978 0.43805880 0.40077430 0.36484280 0.33108864 [19] 0.29569089 0.25829439 0.22059283 0.18261150 0.15179753 0.11914424 [25] 0.08505828 0.04852107 0.01386801 -0.02023941 -0.05463744 -0.08783860 [31] -0.12308479 -0.15998518 -0.19492381 -0.22943368 -0.25699202 -0.28109790 [37] -0.30120987 -0.32270886 -0.34094120 -0.35643214 -0.36488465 -0.37237806 [43] -0.37687895 -0.38205488 -0.38908563 -0.39462461 -0.39980353 -0.40327434 [49] -0.40327147 > (mypacf <- c(rpacf$acf)) [1] 0.9610075282 -0.0232202223 -0.0425872022 -0.0002766409 0.0126045227 [6] -0.0455574678 -0.0485589272 -0.0600973458 -0.0203384239 0.0056656448 [11] 0.0088587868 -0.0391713294 -0.0636441706 -0.0194866928 0.0322451088 [16] -0.0145238361 -0.0064616643 -0.0464280713 -0.0474264960 -0.0284231853 [21] -0.0356228250 0.0526393969 -0.0573926220 -0.0495982967 -0.0523956421 [26] -0.0005875487 -0.0346381137 -0.0491433744 -0.0267334100 -0.0559279531 [31] -0.0533295147 -0.0116165382 -0.0449438163 0.0352537583 0.0086706825 [36] 0.0293491357 -0.0515328716 0.0110344630 -0.0044281960 0.0557297110 [41] -0.0260815854 0.0123339941 -0.0232237121 -0.0521195371 -0.0150697267 [46] -0.0326890762 -0.0127184134 0.0271648619 > 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/4bs1e1413534199.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/57q5k1413534199.tab") > > try(system("convert tmp/1z4ps1413534199.ps tmp/1z4ps1413534199.png",intern=TRUE)) character(0) > try(system("convert tmp/2smhu1413534199.ps tmp/2smhu1413534199.png",intern=TRUE)) character(0) > try(system("convert tmp/3izeg1413534199.ps tmp/3izeg1413534199.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.168 0.215 1.390