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 = '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/11ngm1413637948.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/2rlcb1413637948.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/3e9a71413637948.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.362355468 0.182027391 -0.341639611 0.463026205 [6] -0.295866336 0.252487933 -0.371449314 0.295174462 -0.173856899 [11] 0.180952492 -0.304882423 0.192741125 -0.102143739 0.040181063 [16] -0.103473498 0.119810506 -0.019759947 0.033513509 -0.041309644 [21] 0.052558645 -0.022555827 -0.077675753 0.016608384 0.070401932 [26] -0.052185779 0.008207817 0.070233253 -0.056502239 -0.019139785 [31] -0.037422731 -0.048683581 0.033277799 0.099185053 -0.064775095 [36] -0.032606805 0.002383396 0.091201771 -0.132168953 0.032795936 [41] -0.085718375 0.105296786 -0.003922349 0.059404728 -0.137823314 [46] 0.129198617 -0.127264196 0.119173789 -0.162732427 > (mypacf <- c(rpacf$acf)) [1] -0.362355468 0.058392993 -0.298443578 0.319767847 -0.069048314 [6] 0.090449575 -0.159871998 -0.016583682 0.062662687 -0.057805607 [11] -0.063888990 -0.059007844 0.047426781 -0.177752409 0.073195685 [16] 0.017108732 0.063473463 0.020736353 -0.004108417 0.069834292 [21] -0.087804778 -0.120161403 -0.010876008 0.103071158 -0.118972822 [26] 0.095472167 0.135393810 -0.118317475 -0.018307797 -0.074987976 [31] -0.104546055 -0.003391529 0.124138071 0.018096308 -0.013156086 [36] -0.086431428 0.071322971 -0.095007383 -0.055270811 -0.031555944 [41] 0.010646971 0.085764246 -0.006612095 -0.005789142 0.011406061 [46] -0.115006967 0.026745700 -0.014809021 > 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/4b5wf1413637948.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/5rxq41413637948.tab") > > try(system("convert tmp/11ngm1413637948.ps tmp/11ngm1413637948.png",intern=TRUE)) character(0) > try(system("convert tmp/2rlcb1413637948.ps tmp/2rlcb1413637948.png",intern=TRUE)) character(0) > try(system("convert tmp/3e9a71413637948.ps tmp/3e9a71413637948.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.179 0.182 1.367