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(59400,57200,60500,48400,62700,61600,66000,68200,75900,66000,62700,78100,66000,49500,58300,44000,61600,50600,67100,60500,63800,71500,70400,83600,60500,50600,56100,40700,58300,45100,63800,60500,53900,77000,69300,79200,59400,55000,49500,40700,53900,48400,66000,63800,55000,73700,68200,88000,70400,42900,42900,42900,50600,50600,68200,62700,56100,70400,64900,93500,73700,42900,45100,37400,51700,59400,74800,73700,59400,69300,61600,88000,67100,53900,48400,36300,53900,64900,75900,71500,52800,75900,59400,91300,75900,55000,50600,34100,53900,51700,78100,78100,59400,77000,57200,89100,75900,56100,42900,29700,58300,56100,73700,84700,62700,70400,52800,91300) > 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/1l5lg1439045089.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/2vij01439045089.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/318v31439045089.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/4pwnx1439045089.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/5ic7x1439045089.tab") > > try(system("convert tmp/1l5lg1439045089.ps tmp/1l5lg1439045089.png",intern=TRUE)) character(0) > try(system("convert tmp/2vij01439045089.ps tmp/2vij01439045089.png",intern=TRUE)) character(0) > try(system("convert tmp/318v31439045089.ps tmp/318v31439045089.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.189 0.282 1.454