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(6.81,6.8,6.8,6.85,6.85,6.85,6.85,6.85,6.85,6.86,6.86,6.88,6.88,6.88,6.91,6.91,6.91,6.91,6.99,6.99,6.99,7.02,7.02,7.05,7.05,7.05,7.05,7.1,7.1,7.1,7.1,7.12,7.13,7.18,7.24,7.24,7.24,7.27,7.27,7.27,7.27,7.3,7.3,7.57,7.76,7.94,7.94,7.96,7.96,7.98,7.99,8,8,8.04,8.04,8.04,8.04,8.04,8.07,8.07,8.07,8.07,8.11,8.11,8.12,8.11,8.13,8.15,8.16,8.2,8.2,8.2) > 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/fisher/rcomp/tmp/1dkxv1352827127.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/fisher/rcomp/tmp/2pg5q1352827127.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/fisher/rcomp/tmp/3rfhp1352827127.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.4301428303 0.2531233883 -0.0702770578 -0.0178086732 [6] -0.1066636295 -0.0176946430 -0.0575261846 -0.0546830863 0.0363827433 [11] 0.0963454005 0.0116258847 -0.0509797026 -0.0653384837 -0.0867644027 [16] -0.0611472587 -0.0210560728 -0.0622952173 -0.0410464964 -0.0472508878 [21] -0.0726375103 -0.0967621439 -0.0380905985 -0.0312285510 -0.0104360876 [26] 0.0606126566 0.0193735121 -0.0445911402 -0.0994791801 -0.0133059843 [31] -0.0255970452 -0.0166672774 -0.0400153025 -0.0517627373 -0.0290772906 [36] -0.0090614358 -0.0627069019 -0.0778422916 -0.0716986070 -0.0593226387 [41] 0.0317431909 -0.0013706867 -0.0226218687 -0.0570656885 0.0003924061 [46] 0.0074194829 0.0220087855 0.0027670781 0.0256272618 > (mypacf <- c(rpacf$acf)) [1] 0.4301428303 0.0835612805 -0.2545469969 0.0982105249 -0.0729091067 [6] 0.0148713527 -0.0222951850 -0.0747968603 0.1459232660 0.0474711823 [11] -0.1401246003 -0.0231636891 0.0167861086 -0.0642274448 -0.0036118842 [16] 0.0116792780 -0.0819929980 0.0251380980 -0.0511671108 -0.1041942563 [21] 0.0026437837 0.0271469470 -0.0382548381 0.0004715712 0.0771162356 [26] -0.0767122221 -0.0750231300 -0.0558374436 0.0820408103 -0.0003245566 [31] -0.0972561144 -0.0209403832 -0.0129346939 -0.0117867622 -0.0576621828 [36] -0.0989637404 0.0235551566 -0.0211216552 -0.0954142265 0.0898195475 [41] -0.0843194451 -0.0731782613 0.0122983756 -0.0187453950 0.0081194829 [46] 0.0140671350 -0.0804264018 0.0331278054 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4u7j21352827127.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/fisher/rcomp/tmp/5p0sh1352827127.tab") > > try(system("convert tmp/1dkxv1352827127.ps tmp/1dkxv1352827127.png",intern=TRUE)) character(0) > try(system("convert tmp/2pg5q1352827127.ps tmp/2pg5q1352827127.png",intern=TRUE)) character(0) > try(system("convert tmp/3rfhp1352827127.ps tmp/3rfhp1352827127.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.164 0.493 2.637