R version 2.13.0 (2011-04-13) Copyright (C) 2011 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i486-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(34.74,34.89,34.98,34.93,35.01,35.03,35.03,34.98,34.92,35.04,35.21,35.21,35.21,35.26,35.45,35.53,35.53,35.57,35.57,35.57,35.63,35.92,36.05,36.1,36.1,36.02,36.07,36.17,36.52,36.49,36.49,36.48,36.62,36.63,36.7,36.7,36.7,36.69,36.86,36.85,36.83,36.88,36.88,36.92,36.93,37.06,37.1,37.09,37.09,37.15,37.27,37.43,37.42,37.4,37.4,37.39,37.42,37.7,37.85,37.88) > 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/16tcu1333542930.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/2hliq1333542930.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/33kgp1333542930.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.0000000000 0.1285612247 -0.2477427512 -0.3594664609 -0.0583458877 [6] -0.0092611076 0.1903995221 0.2033882710 -0.0374185267 -0.1845174971 [11] -0.0691525060 0.0486086635 0.0851796416 0.1100534353 -0.0869473877 [16] -0.1940666010 -0.1490534072 0.1339788947 0.0696650120 0.0584197712 [21] -0.1433580729 -0.1705714465 0.0210955321 0.1181268832 0.0635395678 [26] -0.1212426623 -0.1199894367 -0.0760573986 0.0276449131 0.2175137994 [31] 0.1448305449 -0.0084448149 -0.1232509685 -0.1184513988 -0.0427786234 [36] 0.0355088619 0.2381100816 0.1209307530 -0.1151450300 -0.0749510302 [41] 0.0003651938 0.0280262222 -0.0220371084 0.0205454020 0.0221283418 [46] -0.0368104335 -0.0399585083 0.0695138009 0.0735120886 > (mypacf <- c(rpacf$acf)) [1] 0.128561225 -0.268712009 -0.311807771 -0.053072297 -0.191676512 [6] 0.078556560 0.131930504 -0.074841300 -0.020586995 0.038093663 [11] -0.001337593 0.038556210 0.083553212 -0.129051857 -0.107797508 [16] -0.115046746 0.016472429 -0.120950160 -0.021534451 -0.184489072 [21] -0.180947166 0.093609871 -0.070234024 -0.074190564 -0.144450014 [26] -0.155848887 -0.098230352 -0.082819062 0.073551728 -0.054600910 [31] 0.045321625 0.041819642 -0.033840890 -0.035071891 -0.133950814 [36] 0.050839621 0.034220783 -0.071426946 0.062361286 -0.041410607 [41] -0.104006035 -0.105351124 -0.107254594 -0.036525136 -0.074672565 [46] -0.168112802 0.035934336 -0.003673923 > 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/4rcgx1333542930.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/5wv9z1333542930.tab") > > try(system("convert tmp/16tcu1333542930.ps tmp/16tcu1333542930.png",intern=TRUE)) character(0) > try(system("convert tmp/2hliq1333542930.ps tmp/2hliq1333542930.png",intern=TRUE)) character(0) > try(system("convert tmp/33kgp1333542930.ps tmp/33kgp1333542930.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.052 0.191 1.250