R version 3.2.2 (2015-08-14) -- "Fire Safety" Copyright (C) 2015 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(91.04,91.37,91.36,91.4,91.54,91.57,91.57,91.47,91.55,91.71,91.71,92.12,93.28,94.02,94.26,94.19,94.34,94.62,94.9,96.08,96.85,96.61,96.47,96.68,96.43,96.35,96.14,95.39,95.08,94.86,94.8,95.62,96.35,96.77,96.97,96.78,97.71,98.04,98.41,100.05,100.9,100.61,100.71,100.06,100.57,101.03,100.93,100.98,100.46,101.52,101.29,101.84,102.03,101.72,102.23,102.38,102.5,101.5,101.96,101.61) > 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/17nyh1445586929.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/208du1445586929.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/3ju6s1445586929.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.95658363 0.90859439 0.85939373 0.80268749 0.74725929 [7] 0.68955106 0.63260065 0.56918025 0.50742186 0.44954220 0.39164584 [13] 0.34271098 0.29920147 0.25928826 0.21947493 0.18211349 0.14698347 [19] 0.10991019 0.07388382 0.03950927 0.01057665 -0.01257772 -0.03615267 [25] -0.05656576 -0.07392284 -0.09397976 -0.11654862 -0.14489694 -0.17259303 [31] -0.19763653 -0.22510880 -0.24879507 -0.27147314 -0.29687989 -0.32175596 [37] -0.35028563 -0.37493665 -0.39666574 -0.41721850 -0.42854596 -0.42939185 [43] -0.42585949 -0.42051397 -0.41861658 -0.41183665 -0.40135177 -0.39021966 [49] -0.37413111 > (mypacf <- c(rpacf$acf)) [1] 0.9565836262 -0.0760213282 -0.0367727269 -0.1141729765 -0.0077681427 [6] -0.0596268073 -0.0154565379 -0.1174933197 -0.0082092369 -0.0001955794 [11] -0.0295194929 0.0583290518 0.0179483817 0.0019877943 -0.0481321774 [16] -0.0110845443 -0.0246642824 -0.0554319051 -0.0412674596 -0.0233923556 [21] 0.0350728088 0.0355860369 -0.0344470735 0.0046529758 0.0112891841 [26] -0.0632353468 -0.0688939025 -0.1131340695 -0.0314206544 -0.0014251587 [31] -0.0602822716 0.0137011661 -0.0030105304 -0.0541559010 -0.0283829335 [36] -0.0869198956 -0.0039407204 -0.0256821706 -0.0587342036 0.0490599884 [41] 0.1004229992 0.0172068315 -0.0116916154 -0.0911567340 0.0321181587 [46] 0.0043529789 -0.0568166192 0.0016518179 > 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/4f11b1445586929.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/57vvs1445586929.tab") > > try(system("convert tmp/17nyh1445586929.ps tmp/17nyh1445586929.png",intern=TRUE)) character(0) > try(system("convert tmp/208du1445586929.ps tmp/208du1445586929.png",intern=TRUE)) character(0) > try(system("convert tmp/3ju6s1445586929.ps tmp/3ju6s1445586929.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.112 0.219 1.319