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(48.74,48.79,48.82,48.82,49.20,49.30,49.30,49.34,49.47,49.65,49.70,49.75,49.75,49.70,50.09,50.19,50.53,50.55,50.55,50.55,50.58,50.61,50.94,51.01,51.01,51.04,51.15,51.31,51.31,51.34,51.34,51.34,51.47,51.95,51.97,51.92,51.92,51.91,51.97,52.14,52.33,52.40,52.40,52.41,52.71,53.17,53.33,53.32,53.32,53.30,53.31,53.72,53.87,53.91,53.91,53.96,54.02,54.33,54.48,54.54,52.40,52.45,52.38,52.45,52.83,52.76,52.86,52.88,53.32,53.20,53.22,53.22) > 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/1aot01413711306.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/2aiw91413711306.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/31qg11413711306.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.95206704 0.90284409 0.85327078 0.80646079 0.77200845 [7] 0.73600058 0.69672898 0.65365593 0.62063688 0.59358191 0.56490721 [13] 0.53289161 0.47855914 0.41971458 0.36916858 0.32710513 0.29322567 [19] 0.25686366 0.21626097 0.17299066 0.13254629 0.09736735 0.06624020 [25] 0.03268798 -0.00449153 -0.04420560 -0.08177266 -0.10799249 -0.13226842 [31] -0.15911610 -0.18836646 -0.21944991 -0.24782107 -0.26555979 -0.28220079 [37] -0.30283256 -0.32549778 -0.35019244 -0.37069332 -0.38486715 -0.39566593 [43] -0.40792109 -0.42238239 -0.43762312 -0.44497346 -0.44292457 -0.43393010 [49] -0.42667748 > (mypacf <- c(rpacf$acf)) [1] 0.9520670426 -0.0383416474 -0.0294417308 0.0029449804 0.1056909449 [6] -0.0406135038 -0.0569670535 -0.0566566357 0.1013782432 0.0359102971 [11] -0.0516604460 -0.0623432513 -0.2314560625 -0.0683700299 0.0488326747 [16] 0.0375874215 0.0093362342 -0.0519479706 -0.0469667750 -0.0348040071 [21] -0.0380118872 -0.0235960751 0.0192233889 -0.0265049604 -0.0007369412 [26] -0.0417837989 -0.0556061550 0.0380176043 -0.0376073270 -0.0472249139 [31] -0.0211738982 -0.0205155365 -0.0179092660 0.0497808405 -0.0552172088 [36] -0.0626993035 -0.0304652987 -0.0300269530 0.0057230765 -0.0252160655 [41] -0.0172381241 -0.0139141313 -0.0280701099 -0.0397169507 0.0380078894 [46] 0.0237784583 0.0526750469 -0.0053259465 > 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/47bim1413711306.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/572lh1413711306.tab") > > try(system("convert tmp/1aot01413711306.ps tmp/1aot01413711306.png",intern=TRUE)) character(0) > try(system("convert tmp/2aiw91413711306.ps tmp/2aiw91413711306.png",intern=TRUE)) character(0) > try(system("convert tmp/31qg11413711306.ps tmp/31qg11413711306.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.209 0.172 1.392