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(732,768,902,739,744,848,745,752,833,703,824,759,797,840,988,819,831,904,814,798,828,789,930,744,832,826,907,776,835,715,729,733,736,712,711,667,799,661,692,649,729,622,671,635,648,744,624,476,710,515,461,590,415,554,585,513,591,561,684,668,795,776,1043,964,762,1030,939,779,918,839,874,840,794,820,1003,780,607,1001,743,810,716,775,883,633,755,782,882,694,896,674,702,799,791,797,1021,738,1023,955,912,850,1011,872,1074,811,878,1081,956,812,1125,1051,1090,1028,1178,1041,1146,866,875,1116,903,887) > 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/1rob21425578398.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/2t75z1425578398.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/3c4ic1425578398.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.5862169834 0.6432485434 0.6844071715 0.5912618911 [6] 0.5120775341 0.5056534457 0.3543682313 0.4315930583 0.3600232046 [11] 0.1994421168 0.2252125611 0.3058007703 0.0489758664 0.1891152889 [16] 0.0898355680 0.0536373308 0.1043217003 0.0027500762 -0.0208372976 [21] 0.0670748962 -0.0691064642 -0.0749618471 0.0200149586 -0.0682889582 [26] -0.1027708833 0.0098593101 -0.1236709641 -0.0250864494 -0.0310510037 [31] -0.0920241047 0.0372471998 0.0174610034 -0.0482184434 0.0474169391 [36] 0.0350982995 0.0004133065 0.0670705188 0.0224257944 0.0028156182 [41] 0.1156871129 -0.0175505430 -0.0093666286 0.0823390409 -0.0047106468 [46] -0.0282068656 0.0624194214 -0.0455362971 0.0099340115 > (mypacf <- c(rpacf$acf)) [1] 0.586216983 0.456461266 0.407745686 0.118870771 -0.131982053 [6] -0.111113668 -0.299659943 0.104334148 0.149593471 -0.153235703 [11] -0.134317529 0.243861276 -0.193661435 0.136296423 -0.054217097 [16] -0.061395571 0.070749244 -0.100259691 0.054055681 -0.007250962 [21] -0.128143780 -0.001250446 0.146258217 -0.011874229 -0.004603151 [26] 0.003219217 -0.063898046 0.071600403 -0.003064962 0.081571944 [31] 0.128751410 -0.064655334 -0.006297859 -0.061543830 -0.110886618 [36] 0.064691185 0.057787533 -0.056117667 0.015180613 0.010099303 [41] -0.041407766 -0.070875927 -0.022406926 0.136352332 -0.112770652 [46] 0.111154159 -0.021275736 -0.093896365 > 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/4xk2n1425578398.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/51bqj1425578398.tab") > > try(system("convert tmp/1rob21425578398.ps tmp/1rob21425578398.png",intern=TRUE)) character(0) > try(system("convert tmp/2t75z1425578398.ps tmp/2t75z1425578398.png",intern=TRUE)) character(0) > try(system("convert tmp/3c4ic1425578398.ps tmp/3c4ic1425578398.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.178 0.196 1.386