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(109.77,109.77,109.77,109.77,109.77,109.77,109.77,109.77,109.77,109.77,109.77,109.77,109.86,110.12,110.5,113.73,119.84,119.83,113.06,112.45,110.07,110.09,110.72,109.9,109.9,110.06,110.52,116.16,118.54,118.77,113.71,106.98,106.98,106.98,106.98,106.98,106.98,107.43,107.93,111.99,115.4,115.53,115.22,102.75,102.75,102.75,102.75,102.75,102.75,102.87,103.13,108.52,111.6,111.32,108.77,100.05,100.05,100.05,100.05,100.05,100.05,100.07,100.07,109.26,110,110,109.26,99.42,99.42,99.42,99.42,99.42) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '1' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '1' > par3 <- '0' > par2 <- '1' > par1 <- '60' > #'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/1bq1w1369246743.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/2wo0q1369246743.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/3cpsg1369246743.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.760654300 0.621892481 0.531298142 0.427087963 [6] 0.385761585 0.324167502 0.281295890 0.266021487 0.214819751 [11] 0.233263439 0.177037866 0.107256932 0.091820604 0.005836600 [16] -0.035489847 -0.099585446 -0.119797343 -0.125393309 -0.136884308 [21] -0.142980986 -0.121394799 -0.171542348 -0.162767179 -0.180446255 [26] -0.122965201 -0.146602674 -0.239140023 -0.251523055 -0.259762220 [31] -0.270551139 -0.288251313 -0.312960876 -0.276860692 -0.268717795 [36] -0.270255510 -0.225926137 -0.256092142 -0.221290215 -0.149091082 [41] -0.122029821 -0.100689795 -0.094898830 -0.081273657 -0.060334059 [46] -0.056402483 -0.003830327 0.032526097 0.030480870 0.052162452 [51] 0.067684991 0.063680041 0.052749951 0.049660507 0.045018162 [56] 0.027777359 0.013340039 0.006622220 0.003985250 0.001828380 > (mypacf <- c(rpacf$acf)) [1] 0.760654300 0.102745609 0.068837840 -0.045318597 0.090838152 [6] -0.031211851 0.024145822 0.046104512 -0.050430666 0.123532975 [11] -0.123856284 -0.072708438 0.025627364 -0.139677569 -0.015806857 [16] -0.119315353 0.064235703 -0.043221308 0.026612231 -0.045523525 [21] 0.061173694 -0.119701961 0.030160741 -0.031806511 0.182396694 [26] -0.167068794 -0.190944191 -0.002843885 0.015584360 -0.050081738 [31] -0.142129119 -0.020449578 0.089160243 -0.065231702 -0.064864290 [36] 0.031703744 0.004094157 -0.007447324 0.145931068 0.001560056 [41] 0.030053341 -0.091741243 -0.002937055 -0.028045415 0.041113074 [46] -0.033510430 0.070068305 -0.044075684 -0.032426854 -0.048121304 [51] -0.068222801 0.045172580 0.014861563 -0.085060878 -0.021202415 [56] 0.011914907 0.003750797 -0.066553520 -0.054627640 > 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/4p1ta1369246743.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/59hzk1369246743.tab") > > try(system("convert tmp/1bq1w1369246743.ps tmp/1bq1w1369246743.png",intern=TRUE)) character(0) > try(system("convert tmp/2wo0q1369246743.ps tmp/2wo0q1369246743.png",intern=TRUE)) character(0) > try(system("convert tmp/3cpsg1369246743.ps tmp/3cpsg1369246743.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.981 0.378 2.341