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(93.6,103.5,127,108,117.5,111.5,137.6,122.2,103.2,86.9,124.4,104.8,113.6,101.6,148.5,121.2,114.1,108.3,117.2,128.7,118,116.5,131.7,139.9,129.4,107.4,96.1,126.5,110,116.4,109.8,148,124.7,120.5,111.4,117,141.7,123.4,120,132.1,146.7,133,122.5,99.6,122.7,115,139,117.8,125.5,127.5,124.7,134.5,121.3,126.7,127.5,117.7,123,132.1,124.3,113.1,89.2,121.7,108,105.3,85.3,105.3,98.6,114.6,72.2,92.1,97.2,87.1,78.6,78.1,93,83.2,81,65.9,88.6,78.5,85.7,76.3,96.8,86.3,83.8,76.8,85.6,119.2,93.9,91.4,95.7,112.3,99.8,95.2,82.8,111.3,96.5,108.2,97,124.4,109.9,100,99.3,117.6,131.5,116.1,114.2,116.8,116.5,115.8,105.4,89.2,115.8,103.5,111.4,106.4,128.4,115.4,112.7,107.7,111,129.8,116.2,130.5,142.9,159.9,144.4,84.1,75,100.7,86.6,106.8,97.4,113,105.7,113.2,76.9,87.3,103.7,89.3,92.1,92.9,112.2,99,88.7,74.6,101.5,88.3,119.7,120.7,153.5,131.3,102,76,89.3,105.3,90.2,97.7,94.4,103.5,98.5,89.2) > 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/wessaorg/rcomp/tmp/1fjw51413457226.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/2onqb1413457226.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/3e0ny1413457226.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.569324338 0.433434120 0.286998399 0.452195017 [6] 0.325022633 0.235697526 0.275843727 0.475608071 0.444038081 [11] 0.223661204 0.146361819 0.201341002 0.263364912 0.061157249 [16] 0.135621893 0.187840176 0.391414001 0.108035900 0.029004419 [21] -0.046123325 0.054213163 -0.055368272 -0.127655671 -0.078769962 [26] 0.113576773 0.086366678 -0.110809414 -0.174810716 -0.141548641 [31] -0.079748809 -0.248395384 -0.215673434 -0.200294194 -0.005566217 [36] -0.214619912 -0.219667802 -0.292369893 -0.145598782 -0.225919683 [41] -0.281497497 -0.273950111 -0.130416228 -0.104010022 -0.203378095 [46] -0.203309274 -0.168522449 -0.072614149 -0.207885108 -0.191323221 [51] -0.163339480 0.031938339 -0.127395803 -0.126516931 -0.180313483 [56] -0.007782494 -0.075004417 -0.107701537 -0.088346376 0.067847479 [61] 0.055078031 > (mypacf <- c(rpacf$acf)) [1] 0.5693243380 0.1617233356 -0.0181278681 0.3812561817 -0.0984201466 [6] -0.0875561275 0.2810170056 0.2815023493 -0.0340803518 -0.2310345186 [11] 0.0133039276 -0.0008193868 0.0252743234 -0.1784037438 0.2216178966 [16] -0.0111493172 0.1213825318 -0.2363501280 -0.0622402372 -0.0661317023 [21] -0.1371353109 0.0221403280 -0.0495135094 -0.0340824937 0.1328440323 [26] 0.0183042964 -0.1517356891 -0.0423523919 -0.0102382914 -0.0084486033 [31] -0.0518469349 -0.0563068096 -0.1198613952 0.0903220779 -0.0953946275 [36] 0.1178600420 -0.0724397345 0.0168541830 0.0703285759 -0.0881707857 [41] -0.0652269053 -0.0272781183 0.0949442168 0.0341468972 0.0622807958 [46] -0.0014051450 0.0538181171 -0.0115742079 -0.0648947724 0.0864589332 [51] -0.0147011984 -0.1166900175 0.0282659702 -0.0343870108 0.0323496820 [56] -0.0465468687 0.1074824200 0.0952729375 0.0074504742 -0.1341917576 > 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/4czyl1413457226.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/5v2yo1413457226.tab") > > try(system("convert tmp/1fjw51413457226.ps tmp/1fjw51413457226.png",intern=TRUE)) character(0) > try(system("convert tmp/2onqb1413457226.ps tmp/2onqb1413457226.png",intern=TRUE)) character(0) > try(system("convert tmp/3e0ny1413457226.ps tmp/3e0ny1413457226.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.245 0.196 1.455