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(299.81,299.01,296.82,296.67,296.95,296.80,296.80,295.93,293.77,291.02,288.61,284.55,284.55,278.14,273.28,270.14,268.36,267.15,267.15,265.47,261.75,256.51,252.98,251.17,251.17,244.27,240.54,238.92,237.47,235.91,235.91,231.41,224.94,222.19,219.06,217.83,217.83,216.89,213.84,212.90,213.98,215.31,215.31,214.09,213.71,211.54,209.40,207.33,207.33,202.75,200.26,198.99,198.82,198.43,198.43,195.68,195.45,193.65,191.38,189.71,189.71,185.49,183.01,182.38,181.60,182.13,182.13,180.81,180.25,179.84,178.50,178.11,178.11,178.10,177.52,177.34,175.53,176.01,175.94,175.47,175.48,173.76,173.74,173.65,172.00,171.50,170.41,171.50,171.43,170.69,170.40,169.90,170.21,170.55,169.98,169.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/12lu11425494206.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/2hkj41425494206.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/3lcdr1425494206.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.97232307 0.94358028 0.91472207 0.88458978 0.85296863 [7] 0.82027604 0.78608098 0.75121926 0.71633212 0.68142658 0.64688024 [13] 0.61301863 0.57791887 0.54470176 0.51282140 0.48200286 0.45120452 [19] 0.42002663 0.38764735 0.35503042 0.32389504 0.29449908 0.26622487 [25] 0.23779489 0.20821203 0.18121275 0.15572914 0.13051673 0.10558379 [31] 0.08097147 0.05551754 0.03155755 0.01028704 -0.01008722 -0.02888583 [37] -0.04664203 -0.06536985 -0.08382820 -0.10077398 -0.11728163 -0.13472440 [43] -0.15258632 -0.17100199 -0.18907500 -0.20738116 -0.22473803 -0.24079533 [49] -0.25513084 > (mypacf <- c(rpacf$acf)) [1] 0.9723230676 -0.0335580872 -0.0165401616 -0.0383724182 -0.0424875809 [6] -0.0358060370 -0.0445148639 -0.0295498097 -0.0187349372 -0.0187691215 [11] -0.0121042394 -0.0070977885 -0.0432201590 0.0135235224 0.0013235909 [16] -0.0020074377 -0.0220044299 -0.0308561869 -0.0462937752 -0.0302392222 [21] 0.0011229926 0.0079194237 -0.0016878899 -0.0255807503 -0.0438504008 [26] 0.0208091370 0.0010918857 -0.0194366572 -0.0190585648 -0.0200692926 [31] -0.0406492486 -0.0004471095 0.0204114405 -0.0081740254 0.0074265353 [36] -0.0021065882 -0.0386821182 -0.0241917828 -0.0012850788 -0.0172971734 [41] -0.0401222386 -0.0311754065 -0.0321725727 -0.0215007894 -0.0340388192 [46] -0.0045718208 0.0040450536 0.0130593362 > 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/4mtc11425494206.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/5j1sy1425494206.tab") > > try(system("convert tmp/12lu11425494206.ps tmp/12lu11425494206.png",intern=TRUE)) character(0) > try(system("convert tmp/2hkj41425494206.ps tmp/2hkj41425494206.png",intern=TRUE)) character(0) > try(system("convert tmp/3lcdr1425494206.ps tmp/3lcdr1425494206.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.235 1.416