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(122.5,123.1,123.1,124.4,124.4,124.6,124.5,125.9,125.9,125.9,125.9,125.9,125.9,128.2,129.3,129.3,129.3,129.3,129.4,129.6,129.6,129.6,130,130,129.4,130.2,130.2,130.2,130.3,130.3,130.3,130.7,130.7,130.7,130.9,130.9,130.9,131.2,131.8,131.8,131.8,131.9,132,132.3,132.3,132.4,132.8,132.8,132.8,133,133.5,133.5,134.4,134.4,134.5,134.6,135.6,135.6,135.6,135.6,135.6,135.7,136.2,136.2,136.2,136.2,136.2,136.3,136.3,136.3,136.3,136.3,136.3) > 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/1oemk1413718121.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/2ehla1413718121.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/3m4ls1413718121.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.945518322 0.893639451 0.840100007 0.796113516 [6] 0.748899172 0.702571087 0.649684678 0.606304575 0.561767669 [11] 0.515225017 0.465631764 0.416906112 0.364206284 0.328690574 [16] 0.301645645 0.272912158 0.243311068 0.218505112 0.191777371 [21] 0.166225091 0.140075752 0.117340846 0.096854243 0.078597283 [26] 0.053371520 0.032455780 0.011707963 -0.008414807 -0.027940518 [31] -0.048156579 -0.068661840 -0.087534518 -0.106080678 -0.125942234 [36] -0.145178745 -0.162633405 -0.180311964 -0.197468095 -0.210799313 [41] -0.225791104 -0.241473244 -0.256791552 -0.271279573 -0.286644526 [46] -0.302102769 -0.317803567 -0.330416449 -0.344036868 > (mypacf <- c(rpacf$acf)) [1] 0.9455183223 -0.0034477728 -0.0425094362 0.0604925309 -0.0512794642 [6] -0.0223554700 -0.0810487363 0.0520349436 -0.0322749262 -0.0602717429 [11] -0.0438647961 -0.0309492120 -0.0717042135 0.1154168100 0.0694319211 [16] -0.0471754840 -0.0126841960 0.0262161754 -0.0427843806 -0.0369177515 [21] -0.0054484525 0.0185262924 -0.0145506196 -0.0159250825 -0.0760725482 [26] -0.0022133554 -0.0061575218 -0.0045205051 -0.0053241192 -0.0380355148 [31] -0.0076138774 -0.0207402710 -0.0278012120 -0.0359368744 -0.0077452901 [36] 0.0004522416 -0.0252037764 -0.0408681084 0.0143432885 -0.0306828631 [41] -0.0390917839 -0.0179829422 -0.0161080956 -0.0406476512 -0.0327745476 [46] -0.0259349910 -0.0117709015 -0.0452952190 > 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/40v0w1413718121.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/5ctt11413718121.tab") > > try(system("convert tmp/1oemk1413718121.ps tmp/1oemk1413718121.png",intern=TRUE)) character(0) > try(system("convert tmp/2ehla1413718121.ps tmp/2ehla1413718121.png",intern=TRUE)) character(0) > try(system("convert tmp/3m4ls1413718121.ps tmp/3m4ls1413718121.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.195 0.172 1.379