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(86.5,86.6,98.8,84.4,91.4,95.7,78.5,81.7,94.3,98.5,95.4,91.7,92.8,90.6,102.2,91.8,95,102,88.9,89.6,97.9,108.6,100.8,95.1,101,100.9,102.5,105.4,98.4,105.3,96.5,88.1,107.9,107.1,92.5,95.7,85.2,85.5,94.7,86.2,88.8,93.4,83.4,82.9,96.7,96.2,92.8,92.8,90.2,95.9,107.5,98,95,108.5,91.8,91.7,108.3,105.1,104.8,103.2,98.6,102.4,121.2,102.6,108.9,105.5,90.8,99.6,111.6,104.7,103.1,101.7,98.8,101.4,114.2,96.9,98.3,104.8,94.4,94.5,102.4,105.5,101.2,99.5) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1q2651384333731.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/24jp71384333731.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/3azph1384333731.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.329373182 -0.384067238 0.372065820 -0.225054548 [6] -0.078706423 0.369778991 -0.162116344 -0.099822751 0.243068671 [11] -0.343421352 -0.124505947 0.614017825 -0.188182015 -0.304257232 [16] 0.215471159 -0.136027536 -0.047432095 0.276318839 -0.147999116 [21] -0.064994998 0.204940001 -0.343927744 -0.013088368 0.456415495 [26] -0.170187840 -0.228770733 0.156619957 -0.110615463 0.013225319 [31] 0.213744188 -0.159752730 -0.002323992 0.135767484 -0.269586989 [36] 0.024484263 0.324257329 -0.130744698 -0.148571991 0.111676667 [41] -0.096604885 0.068371834 0.126290108 -0.125400655 -0.019118336 [46] 0.110306902 -0.177896843 -0.015202378 0.278980646 > (mypacf <- c(rpacf$acf)) [1] -0.329373182 -0.552491957 -0.010175793 -0.404076297 -0.235168945 [6] 0.007708082 0.035157556 0.119451831 0.297141722 -0.120714672 [11] -0.392022646 0.161791636 0.199117514 0.077730706 -0.158345936 [16] -0.109907015 -0.096787122 -0.067296649 -0.123399350 -0.103663275 [21] 0.053925776 -0.102290218 -0.037356046 -0.028730564 0.038104468 [26] -0.085964805 -0.071604715 -0.090916094 -0.028768242 -0.014890926 [31] -0.056020570 -0.008558622 -0.032873095 0.040367534 -0.016658274 [36] -0.066161499 -0.100787072 -0.041165592 0.032607460 -0.013796317 [41] 0.061890605 -0.018086473 0.095403304 -0.134675626 -0.047108927 [46] -0.049780757 -0.065712763 -0.020863599 > 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/4xtr01384333731.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/5km3o1384333731.tab") > > try(system("convert tmp/1q2651384333731.ps tmp/1q2651384333731.png",intern=TRUE)) character(0) > try(system("convert tmp/24jp71384333731.ps tmp/24jp71384333731.png",intern=TRUE)) character(0) > try(system("convert tmp/3azph1384333731.ps tmp/3azph1384333731.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.206 0.445 2.619