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(790,766,1040,2596,949,758,1023,2730,921,775,907,2603,835,871,836,2542,10471,789,811,996,2596,778,603,990,2371,735,800,706,2241,766,870,647,2283,9491,726,784,884,2394,696,893,674,2263,703,799,793,2295,799,1022,758,2579,9531,1021,944,915,2880,864,1022,891,2777,1087,822,890,2799,1092,967,833,2892,11348,1104,1063,1103,3270,1039,1185,1047,3271,1155,878,879,2912,1133,920,943,2996,12449) > 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/1xcev1413752522.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/22nqr1413752522.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/31wrn1413752522.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.036914070 -0.160143700 -0.142853529 0.109044581 [6] 0.052942118 -0.158935519 -0.160772354 0.066384274 0.096279080 [11] -0.154026401 -0.160281819 0.017484990 0.127486153 -0.137882871 [16] -0.161706324 -0.007920261 0.760618067 0.032816952 -0.120009427 [21] -0.108499020 0.076004839 0.041599085 -0.114152811 -0.125148588 [26] 0.041725172 0.067979767 -0.120285475 -0.125712643 0.004743833 [31] 0.090897925 -0.107353946 -0.127139617 -0.014546770 0.559573506 [36] 0.024902759 -0.089753672 -0.084684397 0.050332473 0.027675816 [41] -0.087996757 -0.095702695 0.024606145 0.049180405 -0.094134904 [46] -0.104822958 -0.002396113 0.063540087 -0.084485227 > (mypacf <- c(rpacf$acf)) [1] 0.036914070 -0.161726725 -0.133690068 0.096358784 0.004002159 [6] -0.157948881 -0.123239059 0.032973032 0.008171876 -0.175585286 [11] -0.111012330 -0.028239703 -0.003934462 -0.200801598 -0.129713574 [16] -0.072677819 0.709984202 -0.098804952 0.077234669 0.047189627 [21] -0.061029564 -0.080362077 0.093582753 0.025692738 -0.028375235 [26] -0.089823039 0.072495572 0.001157910 -0.003420390 -0.082797506 [31] 0.084246497 -0.009734317 0.019643800 -0.030025758 0.040305719 [36] -0.062174370 -0.019359774 -0.001238431 0.022275515 -0.070015521 [41] 0.005842880 -0.016987339 0.019542918 -0.047413581 -0.002921257 [46] -0.016251223 -0.003012230 -0.040412894 > 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/4f6zr1413752522.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/5qf0d1413752522.tab") > > try(system("convert tmp/1xcev1413752522.ps tmp/1xcev1413752522.png",intern=TRUE)) character(0) > try(system("convert tmp/22nqr1413752522.ps tmp/22nqr1413752522.png",intern=TRUE)) character(0) > try(system("convert tmp/31wrn1413752522.ps tmp/31wrn1413752522.png",intern=TRUE)) character(0) > > > proc.time() user system elapsed 1.179 0.182 1.367