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(64800,62400,66000,52800,68400,67200,72000,74400,82800,72000,68400,85200,72000,54000,63600,48000,67200,55200,73200,66000,69600,78000,76800,91200,66000,55200,61200,44400,63600,49200,69600,66000,58800,84000,75600,86400,64800,60000,54000,44400,58800,52800,72000,69600,60000,80400,74400,96000,76800,46800,46800,46800,55200,55200,74400,68400,61200,76800,70800,102000,80400,46800,49200,40800,56400,64800,81600,80400,64800,75600,67200,96000,73200,58800,52800,39600,58800,70800,82800,78000,57600,82800,64800,99600,82800,60000,55200,37200,58800,56400,85200,85200,64800,84000,62400,97200,82800,61200,46800,32400,63600,61200,80400,92400,68400,76800,57600,99600) > 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/1ndo01438198389.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/2i1ej1438198389.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/3qml41438198389.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.34099026 0.16117122 -0.18722410 -0.33959598 0.37095515 [7] -0.34394957 0.41811068 -0.28759624 -0.18407928 0.13441850 -0.31309345 [13] 0.78955157 -0.25518104 0.19065720 -0.16484408 -0.35056914 0.33773501 [19] -0.30827381 0.37650662 -0.22422802 -0.15781700 0.10351417 -0.27386725 [25] 0.60242437 -0.13876351 0.17684239 -0.13654251 -0.30831234 0.24726300 [31] -0.25777595 0.30535560 -0.15311370 -0.11856407 0.09306592 -0.26340316 [37] 0.50136785 -0.07654881 0.09898497 -0.08370534 -0.25128367 0.19095897 [43] -0.25392886 0.27663020 -0.10162638 -0.07910882 0.08589391 -0.25104265 [49] 0.39428607 > (mypacf <- c(rpacf$acf)) [1] -0.340990263 0.050804075 -0.133570111 -0.514820883 0.179815217 [6] -0.220958197 0.076756226 -0.234548990 -0.434092504 -0.217000293 [11] -0.396936872 0.445035918 0.108652141 0.043625259 -0.004305512 [16] -0.015357294 0.049770608 0.089723593 -0.104653523 -0.051051396 [21] -0.005491383 -0.041121740 0.039510049 -0.115361413 0.072225167 [26] 0.043009008 -0.018900953 0.066735686 -0.040516409 -0.017416444 [31] -0.047432673 -0.044357007 0.014553393 0.080648596 -0.100601093 [36] 0.127453823 0.068868463 -0.162689084 -0.038457603 0.054242415 [41] 0.071862454 -0.132689471 -0.007348424 0.009600314 0.124014402 [46] 0.053238359 -0.053354514 -0.098083669 > 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/4g22y1438198389.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/55qvh1438198389.tab") > > try(system("convert tmp/1ndo01438198389.ps tmp/1ndo01438198389.png",intern=TRUE)) character(0) > try(system("convert tmp/2i1ej1438198389.ps tmp/2i1ej1438198389.png",intern=TRUE)) character(0) > try(system("convert tmp/3qml41438198389.ps tmp/3qml41438198389.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.172 0.192 1.375