R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 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(1.65,1.66,1.66,1.67,1.68,1.68,1.68,1.68,1.69,1.7,1.7,1.71,1.72,1.73,1.74,1.74,1.75,1.75,1.75,1.76,1.79,1.83,1.84,1.85,1.87,1.87,1.87,1.88,1.88,1.88,1.88,1.89,1.89,1.89,1.9,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.89,1.9,1.9,1.92,1.93,1.92,1.95,1.96,1.96,1.96,1.96,1.96,1.97,1.97,1.97,1.97,1.97,1.97,1.98,1.98,1.98,1.98,1.98,1.98,1.97,1.98,1.98,1.99,2,2) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1rkl51384808264.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/2rhbg1384808264.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/3k3p71384808264.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.000000000 0.958275381 0.915937149 0.872699970 0.830160896 [6] 0.788404418 0.746214396 0.700734695 0.653160680 0.606136562 [11] 0.559895040 0.511442855 0.463773266 0.418430693 0.374103418 [16] 0.331954950 0.288875675 0.247509804 0.205213127 0.163646412 [21] 0.123444048 0.090010804 0.065874538 0.043800728 0.025333791 [26] 0.015741368 0.004720879 -0.005453298 -0.010359833 -0.015382719 [31] -0.019210240 -0.023619514 -0.025733631 -0.027847749 -0.031009023 [36] -0.032573244 -0.037247078 -0.043666173 -0.051597827 -0.060227586 [41] -0.070369905 -0.081908432 -0.094610467 -0.107894256 -0.121643448 [46] -0.136090744 -0.151585196 -0.168010455 -0.185017467 -0.203071637 [51] -0.223601029 -0.243051407 -0.263316240 -0.284744581 -0.305210257 [56] -0.326141337 -0.344893611 -0.364227638 -0.377543284 -0.389029177 [61] -0.403973734 > (mypacf <- c(rpacf$acf)) [1] 0.9582753806 -0.0288166032 -0.0330561433 -0.0143797102 -0.0136480858 [6] -0.0289840814 -0.0646119555 -0.0518087733 -0.0209726148 -0.0200203290 [11] -0.0585333634 -0.0225634478 -0.0012949877 -0.0182644159 -0.0063910555 [16] -0.0438571701 -0.0099244982 -0.0433120849 -0.0290643518 -0.0215516020 [21] 0.0472870595 0.0830361634 -0.0036375861 0.0194214853 0.0915648302 [26] -0.0329978768 -0.0173088011 0.0393544330 -0.0208963921 -0.0072889614 [31] -0.0337817639 0.0041607532 -0.0071609897 -0.0282613005 0.0013116356 [36] -0.0464185983 -0.0336343820 -0.0390032811 -0.0304380912 -0.0399688240 [41] -0.0284971336 -0.0229410578 -0.0144465134 -0.0112472920 -0.0097938487 [46] -0.0097255592 -0.0307324294 -0.0129618702 -0.0166121510 -0.0624774696 [51] -0.0073620845 -0.0268061263 -0.0427433468 -0.0176467190 -0.0340597718 [56] 0.0008781512 -0.0478014101 0.0315484089 -0.0049328855 -0.0894312078 > 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/4ktkc1384808264.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/547ze1384808264.tab") > > try(system("convert tmp/1rkl51384808264.ps tmp/1rkl51384808264.png",intern=TRUE)) character(0) > try(system("convert tmp/2rhbg1384808264.ps tmp/2rhbg1384808264.png",intern=TRUE)) character(0) > try(system("convert tmp/3k3p71384808264.ps tmp/3k3p71384808264.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.883 0.403 2.276