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(11201,7804,8918,7874,8374,9099,7860,8000,7930,9079,8620,2513,13991,10095,11445,8792,8716,9607,7843,7221,8242,8839,6874,2478,11351,6480,6809,5464,4791,5179,4605,3809,5366,4402,4225,1719,7064,4820,6150,4971,4295,5713,4588,4253,5275,5114,5450,2088,9228,6060,7322,6147,6102,5988,5095,4971,5883,6211,6352,2581,9787,6187,7456,5127,5615,6243,5161,5439,4939,5349,4959,3080,7695,4965,6179,5166,5012,5094,4855,4272,4658,5146,5346,6009) > par8 = '' > par7 = '0.95' > par6 = 'White Noise' > par5 = '12' > par4 = '0' > par3 = '1' > par2 = '1' > par1 = '48' > par8 <- '' > par7 <- '0.95' > par6 <- 'White Noise' > par5 <- '12' > par4 <- '0' > par3 <- '1' > 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/1t10v1413480365.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/2hftk1413480365.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/3ga7p1413480365.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.63314685 0.20657717 -0.11393186 0.06733533 0.08533072 [7] -0.18649278 0.07735672 0.08361821 -0.12944080 0.19911687 -0.50998211 [13] 0.73967713 -0.51508355 0.19368455 -0.09711622 0.04909350 0.05323144 [19] -0.11149455 0.03184581 0.06362231 -0.10140595 0.16500700 -0.38195884 [25] 0.53273468 -0.34867909 0.14104867 -0.08344270 0.04954452 0.03696210 [31] -0.09425082 0.03093194 0.04471944 -0.06849512 0.12711177 -0.31473207 [37] 0.45365839 -0.30442136 0.11009816 -0.06075797 0.04118747 0.02341280 [43] -0.07709732 0.03695537 0.02504161 -0.04691459 0.09751159 -0.24608713 [49] 0.34723063 > (mypacf <- c(rpacf$acf)) [1] -0.6331468540 -0.3243025204 -0.2724283007 -0.1945620971 0.0972169724 [6] -0.0532837393 -0.1666035785 0.0564895709 -0.0564563577 0.1963219456 [11] -0.5312051704 0.2837489739 0.1014113518 0.0221555582 -0.0064563337 [16] -0.0203043153 -0.1252482160 0.0299936657 -0.0038656232 -0.1115145342 [21] -0.0425552013 -0.0789889316 -0.0348158980 -0.0472679532 0.1425613706 [26] 0.0807866418 0.0488362851 0.0500971435 0.0657313775 -0.0744444984 [31] -0.0063930116 -0.0221413946 -0.0331503756 0.0093634105 -0.0854833643 [36] 0.1258533865 0.0377937419 0.0222012871 0.0225810880 0.0213512807 [41] -0.0479342051 0.0229960268 -0.0001823401 -0.0191818828 0.0328566448 [46] 0.0095532485 0.0632513681 -0.0454955258 > 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/4q7er1413480365.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/5p5yw1413480365.tab") > > try(system("convert tmp/1t10v1413480365.ps tmp/1t10v1413480365.png",intern=TRUE)) character(0) > try(system("convert tmp/2hftk1413480365.ps tmp/2hftk1413480365.png",intern=TRUE)) character(0) > try(system("convert tmp/3ga7p1413480365.ps tmp/3ga7p1413480365.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.358 0.262 1.630