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(1.64,1.65,1.65,1.66,1.67,1.67,1.68,1.68,1.69,1.7,1.71,1.72,1.72,1.73,1.73,1.73,1.73,1.74,1.75,1.75,1.75,1.76,1.76,1.76,1.77,1.78,1.78,1.79,1.79,1.79,1.79,1.79,1.83,1.83,1.83,1.83,1.84,1.84,1.84,1.85,1.85,1.85,1.86,1.86,1.86,1.87,1.87,1.88,1.88,1.88,1.89,1.89,1.9,1.91,1.91,1.91,1.91,1.91,1.92,1.92,1.92,1.93,1.94,1.94,1.94,1.95,1.95,1.95,1.95,1.96,1.96,1.97) > 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/1zeoj1413831382.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/21ykd1413831382.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/3e6us1413831382.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.95312578 0.91019437 0.86568584 0.82401613 0.78314593 [7] 0.74006777 0.69826225 0.65581493 0.61369399 0.57284570 0.53530937 [13] 0.50076958 0.46496809 0.43028154 0.39589946 0.35883627 0.32051138 [19] 0.28377456 0.24783726 0.21251986 0.17798007 0.14392437 0.11064628 [25] 0.07563335 0.04189307 0.01256875 -0.01943669 -0.04686847 -0.07571966 [31] -0.10693654 -0.13706038 -0.16844592 -0.18937863 -0.20953373 -0.23063511 [37] -0.25284047 -0.27078759 -0.29031184 -0.31062465 -0.32950710 -0.33975917 [43] -0.35127294 -0.36072550 -0.37080891 -0.38246944 -0.38955631 -0.39727403 [49] -0.40057580 > (mypacf <- c(rpacf$acf)) [1] 0.953125780 0.019067126 -0.037981097 0.005894179 -0.011465038 [6] -0.047245925 -0.012134379 -0.029299310 -0.024225786 -0.011437490 [11] 0.011864786 0.010141888 -0.034523573 -0.012365048 -0.017922827 [16] -0.056139013 -0.044285204 -0.010278355 -0.020689089 -0.022301071 [21] -0.016139031 -0.020736024 -0.021201873 -0.048290193 -0.019696456 [26] 0.015470726 -0.060756577 0.014874812 -0.036330895 -0.063913186 [31] -0.022786486 -0.043826781 0.071845629 -0.012760838 -0.044143393 [36] -0.037142265 0.016924263 -0.052676713 -0.040681153 -0.021127424 [41] 0.059708673 -0.036691051 -0.003988460 -0.022771080 -0.049508708 [46] 0.016302279 -0.026244709 0.010008268 > 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/405c71413831382.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/5cjg81413831382.tab") > > try(system("convert tmp/1zeoj1413831382.ps tmp/1zeoj1413831382.png",intern=TRUE)) character(0) > try(system("convert tmp/21ykd1413831382.ps tmp/21ykd1413831382.png",intern=TRUE)) character(0) > try(system("convert tmp/3e6us1413831382.ps tmp/3e6us1413831382.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.178 0.212 1.406