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(790,766,1040,949,758,1023,921,775,907,835,871,836,789,811,996,778,603,990,735,800,706,766,870,647,726,784,884,696,893,674,703,799,793,799,1022,758,1021,944,915,864,1022,891,1087,822,890,1092,967,833,1104,1063,1103,1039,1185,1047,1155,878,879,1133,920,943,938,900,781,1040,792,653,866,679,799,760,697,750) > 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/1cclu1425547027.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/25u7t1425547027.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/31oya1425547027.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.565818537 -0.041152428 0.222417262 -0.057944728 [6] -0.097648730 0.196145514 -0.238891388 0.082073420 0.224492410 [11] -0.305352945 0.018174519 0.349917140 -0.430179355 0.226013281 [16] -0.007231838 -0.094162181 0.092626168 -0.028051032 -0.093055989 [21] 0.137896463 -0.035032968 -0.185074999 0.238156234 -0.056515899 [26] -0.143908272 0.183952715 -0.129780820 0.047247808 0.046711941 [31] -0.166200373 0.099507793 0.110521290 -0.152658459 -0.040702791 [36] 0.194949779 -0.167238990 0.086117410 -0.010860458 -0.111132345 [41] 0.226721220 -0.179146267 0.002689652 0.079646832 0.012441366 [46] -0.134844420 0.147338566 -0.015159285 -0.127477518 > (mypacf <- c(rpacf$acf)) [1] -5.658185e-01 -5.314457e-01 -2.335701e-01 7.683336e-05 -3.057323e-03 [6] 2.329311e-01 -5.292575e-02 -1.885569e-01 1.647742e-01 7.899704e-02 [11] -1.456952e-01 2.213851e-01 -8.632280e-02 2.406862e-02 -6.148611e-02 [16] -3.119042e-02 5.559286e-02 -1.253900e-01 1.246707e-03 -1.803843e-02 [21] -8.800289e-02 -1.562594e-01 -8.199935e-02 -1.894650e-03 2.525346e-02 [26] 1.846837e-02 -2.893870e-02 -3.999336e-02 -2.024963e-02 -1.553868e-01 [31] -1.401874e-01 2.253862e-02 1.135872e-01 1.558490e-04 -3.281670e-02 [36] -7.984485e-02 2.161035e-02 3.450870e-02 -4.099756e-02 1.368042e-01 [41] -9.989188e-02 -5.559509e-03 -8.085504e-02 -4.105072e-02 -4.928253e-02 [46] 2.258153e-02 1.647112e-01 -4.860171e-02 > 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/48sk31425547027.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/5scxj1425547027.tab") > > try(system("convert tmp/1cclu1425547027.ps tmp/1cclu1425547027.png",intern=TRUE)) character(0) > try(system("convert tmp/25u7t1425547027.ps tmp/25u7t1425547027.png",intern=TRUE)) character(0) > try(system("convert tmp/31oya1425547027.ps tmp/31oya1425547027.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.232 1.411