R version 3.0.2 (2013-09-25) -- "Frisbee Sailing" Copyright (C) 2013 The R Foundation for Statistical Computing 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(1.93,2.02,1.85,1.77,1.81,1.67,1.55,1.62,1.79,1.73,1.77,1.95,2.08,2.26,2.02,1.9,1.97,1.76,1.93,1.91,1.96,1.99,1.98,1.96,1.95,2.26,2.07,2.02,2.07,1.88,1.75,1.78,1.87,1.94,2.03,2.13,2.04,2.18,2.02,1.99,2.09,1.88,1.8,1.77,1.85,1.9,2.03,2.02,2.09,2.3,2.16,2.02,2.31,1.98,1.74,1.82,2.07,2.04,2.07,2.13,2.14,2.43,2.26,2.11,2.19,2.04,2.04,2.05,2.08,1.98,2.07,2.12,2.15,2.35,2.19,2.17,2.3,2.09,1.95,1.89,1.95,1.98,1.95,2.06) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '0' > par2 = '1' > par1 = '60' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > 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/11wz11384955469.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/2xgpg1384955469.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/3xkwj1384955469.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.684054680 0.462834049 0.354114658 0.109497600 [6] -0.045808703 -0.125100409 -0.105441820 -0.042838337 0.145381275 [11] 0.212637356 0.315571414 0.520801208 0.359882583 0.265937709 [16] 0.200882753 -0.029020211 -0.169808795 -0.279846926 -0.265096224 [21] -0.178676876 0.003832225 0.064700047 0.183751532 0.395833335 [26] 0.259712455 0.168855215 0.136283351 -0.057625923 -0.211756487 [31] -0.264951346 -0.228055484 -0.199359071 -0.074164545 0.008236651 [36] 0.085845770 0.257437881 0.197473593 0.143637743 0.107775324 [41] -0.026037383 -0.137160114 -0.231240436 -0.233622273 -0.217348399 [46] -0.143232253 -0.110024734 -0.027624042 0.128334533 0.063997608 [51] 0.001436625 -0.022875869 -0.114915393 -0.182273990 -0.224430005 [56] -0.226361688 -0.241971708 -0.200417205 -0.167133653 -0.133977997 [61] -0.047577782 > (mypacf <- c(rpacf$acf)) [1] 6.840547e-01 -9.579123e-03 7.712246e-02 -3.006290e-01 -4.437846e-02 [6] -6.293804e-02 1.781204e-01 7.005118e-02 3.361624e-01 -1.371846e-01 [11] 2.472470e-01 2.157608e-01 -3.235243e-01 1.063109e-01 -1.201182e-01 [16] -1.544855e-01 3.212695e-03 -1.979979e-01 1.811841e-01 9.926207e-02 [21] 6.210446e-02 -8.915927e-02 1.366958e-01 -6.444022e-04 -1.132025e-01 [26] -7.274072e-02 6.918428e-02 -8.514083e-02 -7.824555e-02 1.657140e-01 [31] 6.827371e-02 -7.687525e-02 -2.830045e-02 -1.212895e-02 -8.789558e-02 [36] 6.817265e-03 7.484622e-02 -3.035226e-03 -1.104773e-02 4.666939e-02 [41] 3.184053e-02 -1.123510e-01 2.478151e-02 -5.624872e-02 -1.289705e-01 [46] -1.010060e-01 8.577732e-02 -2.049061e-02 5.803334e-03 -7.264403e-02 [51] -9.273167e-02 4.016417e-02 8.426898e-02 1.217584e-05 -9.443481e-02 [56] -3.478086e-02 -9.795684e-02 -4.784524e-02 3.261608e-03 -4.073885e-02 > 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/43n661384955469.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/5kycy1384955469.tab") > > try(system("convert tmp/11wz11384955469.ps tmp/11wz11384955469.png",intern=TRUE)) character(0) > try(system("convert tmp/2xgpg1384955469.ps tmp/2xgpg1384955469.png",intern=TRUE)) character(0) > try(system("convert tmp/3xkwj1384955469.ps tmp/3xkwj1384955469.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 2.056 0.473 2.507