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(1143,1162,1169,1184,1169,1189,1192,1198,1168,1179,1173,1172,1125,1127,1123,1132,1114,1127,1129,1139,1117,1131,1132,1140,1105,1126,1129,1139,1123,1101,1110,1128,1101,1134,1139,1137,1141,1165,1146,1134,1141,1159,1166,1192,1171,1179,1181,1195,1167,1176,1181,1197,1194,1173,1179,1184,1193,1193,1193,1191,1222,1198,1218,1219,1260,1235,1256,1258,1295,1294,1318,1262) > 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/1m25b1413637738.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/2o4h81413637738.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/3qej41413637738.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.892719485 0.812081615 0.716462329 0.675249108 [6] 0.578858722 0.532721469 0.458937470 0.429429710 0.370991779 [11] 0.341747670 0.294020850 0.279522717 0.243216463 0.221210729 [16] 0.191217462 0.178128832 0.147176392 0.123622887 0.097805539 [21] 0.067377962 0.021915334 -0.009326181 -0.026224685 -0.039877534 [26] -0.088060257 -0.117398403 -0.147336641 -0.182769400 -0.225346500 [31] -0.255230754 -0.274717352 -0.273829365 -0.279871523 -0.303138042 [36] -0.327046100 -0.333207719 -0.337350687 -0.353046219 -0.349098561 [41] -0.333988764 -0.320130002 -0.309549981 -0.292052352 -0.291798937 [46] -0.283210053 -0.288027994 -0.271075081 -0.258253158 > (mypacf <- c(rpacf$acf)) [1] 0.892719485 0.074530374 -0.104008674 0.201804253 -0.256868638 [6] 0.151958595 -0.086689553 0.065316096 -0.018819928 -0.025021538 [11] 0.029180634 0.014250140 -0.011181014 -0.034489822 0.036792424 [16] -0.022378493 -0.031530664 -0.023826380 0.008651466 -0.096968328 [21] -0.066383335 0.025537628 0.039173915 -0.008512340 -0.197272249 [26] 0.076953573 -0.069773907 -0.126809281 0.030117821 -0.075616417 [31] 0.057957210 0.040582061 -0.037220995 -0.119039820 -0.044481997 [36] 0.020924785 0.002579393 -0.076630346 0.081555681 0.035959946 [41] -0.035704560 0.028722677 -0.036108262 -0.049492897 0.020685127 [46] -0.083024195 0.093701386 0.006894649 > 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/42p0e1413637738.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/5kax91413637738.tab") > > try(system("convert tmp/1m25b1413637738.ps tmp/1m25b1413637738.png",intern=TRUE)) character(0) > try(system("convert tmp/2o4h81413637738.ps tmp/2o4h81413637738.png",intern=TRUE)) character(0) > try(system("convert tmp/3qej41413637738.ps tmp/3qej41413637738.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.165 0.179 1.353