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(98.71,100.46,100.46,100.67,100.01,100.01,99.99,99.98,99.87,99.91,96.59,96.99,96.68,96.57,96.55,96.78,95.99,97.54,97.45,97.58,97.66,97.67,97.71,98.52,98.87,97.91,97.92,97.97,97.97,97.97,97.58,97.57,96.7,96.72,96.72,96.74,101.2,100.59,100.58,99.62,99.63,99.17,99.17,98.99,98.92,99.52,99.45,99.04,99.23,98.71,98.73,97.1,100.94,100.93,101.02,101.01,100.86,100.56,100.75,100.15,99.49,99.15,99.15,99.14,98.77,98.8,99.29,98.38,98.31,98.24,96.99,96.81) > 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/101hg1445624877.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/2v9vl1445624877.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/341l51445624877.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.189168817 0.065363906 -0.087121041 -0.039910765 [6] -0.082475810 0.073681934 -0.083273982 -0.028296402 -0.055143852 [11] 0.054275569 -0.120447417 0.066134946 -0.090375647 0.052673422 [16] -0.218358188 0.335992533 0.008189335 -0.052964935 0.142905095 [21] -0.098215490 0.048149895 0.038798387 -0.019230929 -0.094866881 [26] 0.010261129 -0.209054519 -0.020114889 0.007263763 0.091698957 [31] 0.038387318 -0.026528372 -0.054741091 0.047025258 -0.122875865 [36] 0.224980302 -0.082385052 0.037573842 -0.030441371 0.034983079 [41] -0.047502934 0.097667420 -0.204926515 0.001835444 -0.011282143 [46] 0.021836934 -0.014878114 0.016381597 -0.070134919 > (mypacf <- c(rpacf$acf)) [1] -0.189168817 0.030676830 -0.071973303 -0.073515337 -0.101364289 [6] 0.039958152 -0.069810190 -0.083753565 -0.078998857 0.021756323 [11] -0.124242679 -0.019525768 -0.090159329 -0.009517959 -0.248265746 [16] 0.234215992 0.124126722 -0.134413492 0.150121247 -0.043622921 [21] 0.091306561 0.007281599 0.021221664 -0.068917463 0.018182565 [26] -0.293624368 -0.026394751 -0.035985619 0.065631031 0.044080003 [31] 0.012718264 -0.091466344 -0.096388809 -0.040223330 0.066824647 [36] 0.028344843 -0.085708621 -0.063395773 -0.044993685 0.021961095 [41] -0.030797205 -0.063588360 0.010400121 0.001950675 -0.035624024 [46] -0.082122876 -0.044649082 -0.020908845 > 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/44m8x1445624877.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/56q2u1445624877.tab") > > try(system("convert tmp/101hg1445624877.ps tmp/101hg1445624877.png",intern=TRUE)) character(0) > try(system("convert tmp/2v9vl1445624877.ps tmp/2v9vl1445624877.png",intern=TRUE)) character(0) > try(system("convert tmp/341l51445624877.ps tmp/341l51445624877.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.219 0.212 1.440