R version 2.15.3 (2013-03-01) -- "Security Blanket" Copyright (C) 2013 The R Foundation for Statistical Computing ISBN 3-900051-07-0 Platform: i686-pc-linux-gnu (32-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(15.13,15.25,15.33,15.36,15.4,15.4,15.41,15.47,15.54,15.55,15.59,15.65,15.75,15.86,15.89,15.94,15.93,15.95,15.99,15.99,16.06,16.08,16.07,16.11,16.15,16.18,16.3,16.42,16.49,16.5,16.58,16.64,16.66,16.81,16.91,16.92,16.95,17.11,17.16,17.16,17.27,17.34,17.39,17.43,17.45,17.5,17.56,17.65,17.62,17.7,17.72,17.71,17.74,17.75,17.78,17.8,17.86,17.88,17.89,17.94,17.98,18.1,18.14,18.19,18.23,18.24,18.27,18.3,18.34,18.36,18.36,18.4,18.43,18.47,18.56,18.58,18.61,18.61,18.69,18.74,18.75,18.81,18.85,18.88) > 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/fisher/rcomp/tmp/1abjr1363687810.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/fisher/rcomp/tmp/20dhs1363687810.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/fisher/rcomp/tmp/3t98i1363687810.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.965319861 0.931772949 0.899005037 0.866107789 [6] 0.832612579 0.798505618 0.764383642 0.729653429 0.695513552 [11] 0.660542895 0.626296221 0.592572527 0.559815653 0.528352932 [16] 0.496054533 0.463797740 0.430703744 0.397271377 0.363954757 [21] 0.329378148 0.295508183 0.261710753 0.227113851 0.194065291 [26] 0.161274256 0.128639429 0.097184434 0.067193488 0.038521961 [31] 0.009126248 -0.019293593 -0.047390337 -0.075716969 -0.102415212 [36] -0.127979949 -0.153021066 -0.179028880 -0.201399344 -0.222646981 [41] -0.243884725 -0.263427968 -0.281905163 -0.299291884 -0.315406172 [46] -0.330030323 -0.344440802 -0.357578084 -0.366957115 > (mypacf <- c(rpacf$acf)) [1] 0.965319861 -0.001019486 -0.005674404 -0.018791175 -0.026332256 [6] -0.027575338 -0.019670780 -0.028480834 -0.011605215 -0.032145222 [11] -0.010485389 -0.013162457 -0.006382202 -0.001262563 -0.031897777 [16] -0.021406203 -0.034840129 -0.029474240 -0.022707002 -0.043360787 [21] -0.016088244 -0.024573400 -0.038528370 -0.004130950 -0.023077697 [26] -0.024766829 -0.010742549 -0.007758403 -0.007684785 -0.038814887 [31] -0.015779248 -0.024782530 -0.034862894 -0.006264453 -0.013462777 [36] -0.021563532 -0.043128533 0.020318866 -0.010480204 -0.028294202 [41] -0.004902077 -0.013254893 -0.016369112 -0.009743083 -0.008254329 [46] -0.024864991 -0.010675358 0.027061500 > lengthx <- length(x) > sqrtn <- sqrt(lengthx) > > #Note: the /var/fisher/rcomp/createtable file can be downloaded at http://www.wessa.net/cretab > load(file="/var/fisher/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/fisher/rcomp/tmp/4onkp1363687810.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/fisher/rcomp/tmp/5u8jk1363687810.tab") > > try(system("convert tmp/1abjr1363687810.ps tmp/1abjr1363687810.png",intern=TRUE)) character(0) > try(system("convert tmp/20dhs1363687810.ps tmp/20dhs1363687810.png",intern=TRUE)) character(0) > try(system("convert tmp/3t98i1363687810.ps tmp/3t98i1363687810.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.790 0.280 2.055