R version 2.15.2 (2012-10-26) -- "Trick or Treat" Copyright (C) 2012 The R Foundation for Statistical Computing ISBN 3-900051-07-0 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(20.7,20.4,20.3,20.4,19.8,19.5,23.1,23.5,23.5,22.9,21.9,21.5,20.5,20.2,19.4,19.2,18.8,18.8,22.6,23.3,23,21.4,19.9,18.8,18.6,18.4,18.6,19.9,19.2,18.4,21.1,20.5,19.1,18.1,17,17.1,17.4,16.8,15.3,14.3,13.4,15.3,22.1,23.7,22.2,19.5,16.6,17.3,19.8,21.2,21.5,20.6,19.1,19.6,23.4,24.3,24.1,22.8,22.5,23.8,24.9,25.2,24.3,22.8,20.7,19.8,22.5,22.6,22.5,21.8,21.2,20.6,19.9,18.7,17.6,16.4,15.9,16.8,22.8,24,22.2,17.9,16,16) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/168z31358257531.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/2ifp31358257531.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/3cqpe1358257531.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.367614811 -0.218934643 -0.463522395 -0.364460190 [6] 0.015150973 0.241438359 0.151913306 -0.096551235 -0.196995835 [11] -0.154836981 0.146674669 0.528642601 0.091273025 -0.221656597 [16] -0.276050003 -0.152194747 0.124793914 0.227351181 0.071458317 [21] -0.169217721 -0.250253781 -0.180751784 0.124902781 0.463970732 [26] 0.087994714 -0.185590494 -0.224350322 -0.111548908 0.118404727 [31] 0.162576501 -0.005220727 -0.225529972 -0.258951037 -0.113876991 [36] 0.206679181 0.489127125 0.125671841 -0.162924179 -0.241575923 [41] -0.147576517 0.062605544 0.126121909 0.057482620 -0.060583883 [46] -0.119841844 -0.101893613 0.030152042 0.207546927 0.045299986 [51] -0.016955711 -0.013875636 0.022956261 0.043258310 -0.013989192 [56] -0.057549135 -0.086791867 -0.079864027 -0.010852962 0.084052062 [61] 0.196600631 > (mypacf <- c(rpacf$acf)) [1] 0.367614811 -0.409402166 -0.277241653 -0.200398678 0.039537797 [6] -0.037557430 -0.123445978 -0.174454437 -0.068371412 -0.143139938 [11] 0.136264005 0.431292009 -0.436880377 0.178113889 0.145304836 [16] 0.002032576 0.012801972 0.051528014 -0.032667991 -0.127796464 [21] -0.118591405 -0.012361737 -0.014822219 0.007958443 -0.154404738 [26] -0.006750921 0.031093142 -0.003281068 -0.030279822 -0.053772533 [31] -0.070658616 -0.184632085 -0.122215653 0.005922003 -0.042669200 [36] -0.003909148 0.018047800 0.047337715 0.000159161 0.036790197 [41] -0.010685146 -0.013291519 0.082139139 0.107865960 -0.040416596 [46] -0.062300852 -0.152559193 -0.150041614 0.083565861 0.046884300 [51] -0.042059977 0.040260322 -0.074750913 -0.013149603 0.035253279 [56] 0.019050085 -0.025405156 0.028139125 -0.018601400 0.034784458 > 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/49urp1358257531.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/5bw6v1358257531.tab") > > try(system("convert tmp/168z31358257531.ps tmp/168z31358257531.png",intern=TRUE)) character(0) > try(system("convert tmp/2ifp31358257531.ps tmp/2ifp31358257531.png",intern=TRUE)) character(0) > try(system("convert tmp/3cqpe1358257531.ps tmp/3cqpe1358257531.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.801 0.344 2.132