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(111,111,112,115,115,115,116,116,112,110,111,111,108,109,112,113,114,115,116,114,115,117,121,119,119,119,122,123,127,130,131,126,125,121,114,109,108,110,110,111,113,116,115,117,116,115,117,117,119,118,122,124,125,125,124,124,125,125,126,129,131,132,135,137,138,136,136,136,138,138,138,138) > 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/1c3av1337798216.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/2k6s21337798216.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/3qv5l1337798216.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.00000000 0.93615523 0.84965482 0.75446584 0.66060868 0.56586364 [7] 0.48604674 0.42511443 0.36243562 0.29613210 0.23788783 0.18964443 [13] 0.13077083 0.06844815 0.01981448 -0.01739380 -0.05415814 -0.07968247 [19] -0.09018597 -0.09822095 -0.11118320 -0.11553982 -0.11076393 -0.09773365 [25] -0.10323671 -0.10488577 -0.10776420 -0.10615932 -0.10436906 -0.08771407 [31] -0.05182325 -0.01908392 0.01800700 0.06237174 0.10240926 0.12423543 [37] 0.14154901 0.15008134 0.14328060 0.11271681 0.07295708 0.03084105 [43] -0.02370533 -0.07861273 -0.11956280 -0.15043882 -0.18343210 -0.20914181 [49] -0.23713464 > (mypacf <- c(rpacf$acf)) [1] 0.9361552342 -0.2162533092 -0.0891611785 -0.0250411982 -0.0683085155 [6] 0.0681033162 0.0698498843 -0.1191454801 -0.0772573076 0.0324036050 [11] 0.0207087187 -0.1436845558 -0.0528636577 0.0611101873 0.0128817259 [16] -0.0468131642 0.0433593868 0.0214572323 -0.0400382428 -0.0283997259 [21] 0.0565997509 0.0076539858 0.0666494335 -0.1688971264 0.0205244679 [26] -0.0288618925 0.0703074497 0.0007901807 0.0642417954 0.1082606398 [31] -0.0270109098 0.0667822257 0.0704723351 -0.0532221902 -0.0486615538 [36] 0.0605697396 -0.0731945507 -0.1015312305 -0.1156583038 -0.0793821197 [41] -0.0706087290 -0.1038550417 0.0284808680 0.0270112467 -0.0053468582 [46] -0.0432931254 0.0742591512 -0.1412605034 > 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/4htnw1337798216.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/5mmkd1337798216.tab") > > try(system("convert tmp/1c3av1337798216.ps tmp/1c3av1337798216.png",intern=TRUE)) character(0) > try(system("convert tmp/2k6s21337798216.ps tmp/2k6s21337798216.png",intern=TRUE)) character(0) > try(system("convert tmp/3qv5l1337798216.ps tmp/3qv5l1337798216.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.007 0.244 1.258