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(50,45,43,40,43,47,44,41,31,41,40,31,43,22,17,21,29,23,15,24,24,27,17,22,26,12,13,20,15,23,27,17,22,16,20,8,24,18,28,25,11,33,34,23,13,23,26,15,29,23,26,17,32,25,26,32,24,24,28,26,27,45,47,29,40,25,35,26,32,21,32,16,35,19,28,29,29,26,35,38,27,28,29,26,40,20,28,34,38,32,51,27,23,44,37,26) > 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/163l51425563471.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/2cfat1425563471.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/30qn61425563471.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.432948633 0.438929338 0.437114976 0.435766281 [6] 0.287436658 0.334784096 0.235727839 0.146174095 0.215538840 [11] 0.144369232 0.102900433 0.142025942 -0.049169278 0.041509423 [16] -0.033967602 -0.013328095 -0.094790878 0.008747017 -0.114790701 [21] -0.008580072 -0.131826748 -0.059677704 -0.130134259 -0.132559809 [26] -0.142683413 -0.074060824 -0.146195721 -0.178778045 -0.066339123 [31] -0.163154359 -0.151964006 -0.079533622 -0.177217132 -0.159124239 [36] -0.232835612 -0.094115621 -0.176572798 -0.079379612 -0.209402710 [41] -0.147411022 -0.108731778 -0.115299821 -0.174488211 -0.239594450 [46] -0.085745140 -0.138074646 -0.166887980 -0.069161218 > (mypacf <- c(rpacf$acf)) [1] 0.432948633 0.309498644 0.233965358 0.187616242 -0.063408447 [6] 0.059495373 -0.067298585 -0.130886172 0.087338384 -0.026628986 [11] -0.002208965 0.079205688 -0.262433154 0.070098249 -0.097454621 [16] 0.009125296 0.019454835 0.046145400 -0.037105060 0.109973085 [21] -0.217151301 0.100649912 -0.118824718 -0.082119481 0.091523782 [26] -0.006402206 -0.004915113 -0.070677804 0.043978591 -0.107902054 [31] 0.027178407 -0.010068166 -0.011762763 -0.080503047 -0.135536865 [36] 0.094911554 0.009934774 0.021936039 -0.043637005 -0.098470236 [41] 0.046526272 0.019951263 -0.172398785 -0.134043037 0.183189293 [46] -0.033189598 -0.037113826 0.085467568 > 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/4wswh1425563471.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/5hymf1425563471.tab") > > try(system("convert tmp/163l51425563471.ps tmp/163l51425563471.png",intern=TRUE)) character(0) > try(system("convert tmp/2cfat1425563471.ps tmp/2cfat1425563471.png",intern=TRUE)) character(0) > try(system("convert tmp/30qn61425563471.ps tmp/30qn61425563471.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.215 1.394